Pengxy 9 月之前
父節點
當前提交
9262f54f98
共有 20 個文件被更改,包括 1377 次插入29 次删除
  1. 7 0
      MicroServices/Business/Business.Application.Contracts/Sqe/ISqeExcelService.cs
  2. 544 5
      MicroServices/Business/Business.Application/SqeManagement/SqeExcelService.cs
  3. 5 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_process.cs
  4. 6 2
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_test.cs
  5. 105 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_test_avg.cs
  6. 199 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_test_statistics.cs
  7. 2 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_fct_data.cs
  8. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_file_upload.cs
  9. 5 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_fpy.cs
  10. 5 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_op.cs
  11. 5 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_oqc.cs
  12. 51 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_transfer.cs
  13. 199 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/v_sqe_cto_test_data.cs
  14. 139 0
      MicroServices/Business/Business.Domain/StructuredDB/Sqe/v_sqe_op_data_detail.cs
  15. 32 0
      MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs
  16. 4 1
      MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/Sqe/BusinessSqeDbContext.cs
  17. 3 1
      MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/ISqeRepository.cs
  18. 23 19
      MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/SqeRepository.cs
  19. 36 0
      MicroServices/Business/Business.HttpApi/Controllers/SqeController.cs
  20. 6 0
      MicroServices/Business/QuartzSettings/logs/logs.txt

+ 7 - 0
MicroServices/Business/Business.Application.Contracts/Sqe/ISqeExcelService.cs

@@ -61,5 +61,12 @@ namespace Business.VSM
 
         public string Import_Fct_From_Data(String data, string create_by, DateTime create_date, string create_org);
 
+
+        public string Compute_Test(int upload_id, string create_by, DateTime create_date, string create_org);
+
+        public string Compute_Test(string startDate, string endDate, string item_no, string item_batch, string org, string standard_no, int sample_count);
+
+        public string Compute_op_query(string startDate, string endDate, string item_no, string item_batch, string org);
+
     }
 }

+ 544 - 5
MicroServices/Business/Business.Application/SqeManagement/SqeExcelService.cs

@@ -2,12 +2,21 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
+using System.Linq.Expressions;
 using System.Reflection;
 using System.Text;
 using Business.EntityFrameworkCore.SqlRepositories;
+using Business.StructuredDB;
 using Business.StructuredDB.Sqe;
+using MathNet.Numerics.Statistics;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using NPOI.SS.Formula.Functions;
+using NPOI.XWPF.UserModel;
+using RazorEngine.Compilation.ImpromptuInterface.Optimization;
 using Volo.Abp.Application.Services;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
 
 namespace Business.VSM
 {
@@ -22,8 +31,10 @@ namespace Business.VSM
         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_avg> _sqe_cto_test_avg;
         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_cto_test_statistics> _sqe_cto_test_statistics;
         private readonly ISqeRepository<sqe_file_data> _sqe_file_data;
         private readonly ISqeRepository<sqe_file_upload> _sqe_file_upload;
         private readonly ISqeRepository<sqe_oqc> _sqe_oqc;
@@ -36,6 +47,9 @@ namespace Business.VSM
         private readonly ISqeRepository<sqe_op_data_detail> _sqe_op_data_detail;
         private readonly ISqeRepository<sqe_fct> _sqe_fct;
         private readonly ISqeRepository<sqe_fct_data> _sqe_fct_data;
+        private readonly ISqeRepository<v_sqe_cto_test_data> _v_sqe_cto_test_data;
+        private readonly ISqeRepository<v_sqe_op_data_detail> _v_sqe_op_data_detail;
+
 
 
         public SqeExcelService(
@@ -43,8 +57,10 @@ namespace Business.VSM
             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_avg> sqe_cto_test_avg,
             ISqeRepository<sqe_cto_test_data> sqe_cto_test_data,
             ISqeRepository<sqe_cto_test_standard> sqe_cto_test_standard,
+            ISqeRepository<sqe_cto_test_statistics> sqe_cto_test_statistics,
             ISqeRepository<sqe_file_data> sqe_file_data,
             ISqeRepository<sqe_file_upload> sqe_file_upload,
             ISqeRepository<sqe_oqc> sqe_oqc,
@@ -56,7 +72,9 @@ namespace Business.VSM
             ISqeRepository<sqe_op_data> sqe_op_data,
             ISqeRepository<sqe_op_data_detail> sqe_op_data_detail,
             ISqeRepository<sqe_fct> sqe_fct,
-            ISqeRepository<sqe_fct_data> sqe_fct_data
+            ISqeRepository<sqe_fct_data> sqe_fct_data,
+            ISqeRepository<v_sqe_cto_test_data> v_sqe_cto_test_data,
+            ISqeRepository<v_sqe_op_data_detail> v_sqe_op_data_detail
             )
         {
             WLLog = new LoggerHelper();
@@ -64,8 +82,10 @@ namespace Business.VSM
             _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_avg = sqe_cto_test_avg;
             _sqe_cto_test_data = sqe_cto_test_data;
             _sqe_cto_test_standard = sqe_cto_test_standard;
+            _sqe_cto_test_statistics = sqe_cto_test_statistics;
             _sqe_file_data = sqe_file_data;
             _sqe_file_upload = sqe_file_upload;
             _sqe_oqc = sqe_oqc;
@@ -79,6 +99,8 @@ namespace Business.VSM
             _sqe_fct = sqe_fct;
             _sqe_fct_data = sqe_fct_data;
 
+            _v_sqe_cto_test_data = v_sqe_cto_test_data;
+            _v_sqe_op_data_detail = v_sqe_op_data_detail;
         }
 
         ///// <summary>
@@ -515,6 +537,25 @@ namespace Business.VSM
         //    return tables;
         //}
 
+        /// <summary>
+        /// 依据上传文件标识,获取上传文件对象
+        /// </summary>
+        /// <param name="upload_id"></param>
+        /// <returns></returns>
+        public sqe_file_upload Get_Sqe_file_upload(int upload_id)
+        {
+            try
+            {
+                List<sqe_file_upload> uploads = _sqe_file_upload.Select(a => a.id == upload_id);
+                sqe_file_upload _Upload = _sqe_file_upload.Select(a => a.id == upload_id).First();
+                return _Upload;
+            }
+            catch (Exception ex)
+            {
+                return null;
+            }
+        }
+
 
 
         /// <summary>
@@ -530,7 +571,7 @@ namespace Business.VSM
             StringBuilder stringBuilder = new StringBuilder();
             try
             {
-
+                sqe_file_upload sqe_File_Upload = Get_Sqe_file_upload(upload_id);
                 List<sqe_file_data> datas = LoadData_file_data(upload_id);
                 if (datas == null || datas.Count == 0)
                 {
@@ -591,6 +632,10 @@ namespace Business.VSM
                     return stringBuilder.ToString();
                 }
                 _sqe_cto_test_data.Insert(test_Datas);
+
+                sqe_File_Upload.item_no = test.item_no;
+                sqe_File_Upload.item_name = test.item_name;
+                _sqe_file_upload.Update(sqe_File_Upload);
                 _sqe_cto_test.CommitTransaction();
                 _sqe_cto_test_standard.CommitTransaction();
             }
@@ -624,10 +669,12 @@ namespace Business.VSM
             sqe_cto_test model = new sqe_cto_test();
             DateTime timeValue;
             decimal realValuel;
+            int intValue;
             if (datas != null && datas.Count >= 5)
             {
                 try
                 {
+                    model.file_id = datas[0].file_id;
                     sqe_file_data data = datas[1];
                     if (DateTime.TryParse(data.c2, out timeValue))
                     {
@@ -663,9 +710,9 @@ namespace Business.VSM
                     data = datas[4];
                     model.device_name = data.c2;
                     model.device_no = data.c4;
-                    if (decimal.TryParse(data.c8, out realValuel))
+                    if (int.TryParse(data.c8, out intValue))
                     {
-                        model.sampling_number = realValuel;
+                        model.sampling_number = intValue;
                     }
                 }
                 catch (Exception ex)
@@ -1445,7 +1492,7 @@ namespace Business.VSM
             StringBuilder stringBuilder = new StringBuilder();
             try
             {
-
+                sqe_file_upload sqe_File_Upload = Get_Sqe_file_upload(upload_id);
                 List<sqe_file_data> datas = LoadData_file_data(upload_id);
                 if (datas == null || datas.Count == 0)
                 {
@@ -1507,6 +1554,10 @@ namespace Business.VSM
                     return stringBuilder.ToString();
                 }
                 _sqe_cto_process_data.Insert(test_Datas);
+                sqe_File_Upload.item_no = test.item_no;
+                sqe_File_Upload.item_name = test.item_name;
+                _sqe_file_upload.Update(sqe_File_Upload);
+
                 _sqe_cto_process.CommitTransaction();
                 _sqe_cto_process_standard.CommitTransaction();
             }
@@ -1533,6 +1584,7 @@ namespace Business.VSM
             {
                 try
                 {
+                    model.file_id = datas[0].file_id;
                     sqe_file_data data = datas[1];
                     if (DateTime.TryParse(data.c2, out timeValue))
                     {
@@ -2326,6 +2378,7 @@ namespace Business.VSM
             StringBuilder stringBuilder = new StringBuilder();
             try
             {
+                sqe_file_upload sqe_File_Upload = Get_Sqe_file_upload(upload_id);
 
                 List<sqe_file_data> datas = LoadData_file_data(upload_id);
                 if (datas == null || datas.Count == 0)
@@ -2381,6 +2434,9 @@ namespace Business.VSM
                     return stringBuilder.ToString();
                 }
                 _sqe_op_data_detail.Insert(test_Datas);
+                sqe_File_Upload.item_no = standards[0].item_no;
+                sqe_File_Upload.item_name = standards[0].item_name;
+                _sqe_file_upload.Update(sqe_File_Upload);
                 _sqe_op.CommitTransaction();
                 _sqe_op_data.CommitTransaction();
             }
@@ -2411,6 +2467,10 @@ namespace Business.VSM
             model.create_by = create_by;
             model.create_date = create_date;
             model.create_org = create_org;
+            if (datas != null && datas.Count > 0)
+            {
+                model.file_id = datas[0].file_id;
+            }
             errorMsg = string.Empty;
             errorMsg = "";
             return model;
@@ -2606,6 +2666,7 @@ namespace Business.VSM
             StringBuilder stringBuilder = new StringBuilder();
             try
             {
+                sqe_file_upload sqe_File_Upload = Get_Sqe_file_upload(upload_id);
 
                 List<sqe_file_data> datas = LoadData_file_data(upload_id);
                 if (datas == null || datas.Count == 0)
@@ -2666,6 +2727,9 @@ namespace Business.VSM
                 }
                 _sqe_fpy_data.BeginTransaction();
                 _sqe_fpy_data.Insert(standards);
+                sqe_File_Upload.item_no = standards[0].item_no;
+                sqe_File_Upload.item_name = standards[0].item_name;
+                _sqe_file_upload.Update(sqe_File_Upload);
 
                 _sqe_fpy.CommitTransaction();
                 _sqe_fpy_data.CommitTransaction();
@@ -2697,6 +2761,10 @@ namespace Business.VSM
             model.create_by = create_by;
             model.create_date = create_date;
             model.create_org = create_org;
+            if (datas != null && datas.Count > 0)
+            {
+                model.file_id = datas[0].file_id;
+            }
             errorMsg = string.Empty;
             errorMsg = "";
             return model;
@@ -2786,6 +2854,7 @@ namespace Business.VSM
             StringBuilder stringBuilder = new StringBuilder();
             try
             {
+                sqe_file_upload sqe_File_Upload = Get_Sqe_file_upload(upload_id);
 
                 List<sqe_file_data> datas = LoadData_file_data(upload_id);
                 if (datas == null || datas.Count == 0)
@@ -2846,6 +2915,10 @@ namespace Business.VSM
                     return stringBuilder.ToString();
                 }
                 _sqe_oqc_data.Insert(test_Datas);
+                sqe_File_Upload.item_no = test.item_no;
+                sqe_File_Upload.item_name = test.item_name;
+                _sqe_file_upload.Update(sqe_File_Upload);
+
                 _sqe_oqc.CommitTransaction();
                 _sqe_oqc_standard.CommitTransaction();
             }
@@ -2881,6 +2954,7 @@ namespace Business.VSM
             {
                 try
                 {
+                    model.file_id = datas[0].file_id;
                     sqe_file_data data = datas[1];
                     model.supp_no = data.c2;
                     model.item_name = data.c4;
@@ -3244,5 +3318,470 @@ namespace Business.VSM
         }
 
         #endregion Fct
+
+        /// <summary>
+        /// 依据上传文件id,生成该文件上传的数据统计
+        /// </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 Compute_Test(int upload_id, string create_by, DateTime create_date, string create_org)
+        {
+            StringBuilder stringBuilder = new StringBuilder();
+
+            //查询原始记录
+            List<sqe_cto_test> tests = _sqe_cto_test.Select(a => a.file_id == upload_id).OrderBy(a => a.id).ToList();
+            if (tests == null || tests.Count == 0)
+            {
+                stringBuilder.AppendLine("该id对应的上传数据记录不存在!");
+                return stringBuilder.ToString();
+            }
+            sqe_cto_test test = tests[0];
+            List<sqe_cto_test_standard> test_standards = _sqe_cto_test_standard.Select(a => a.test_id == test.id).OrderBy(a => a.id).ToList();
+            if (test_standards == null || test_standards.Count == 0)
+            {
+                stringBuilder.AppendLine("该id对应的检验标准数据记录不存在!");
+                return stringBuilder.ToString();
+            }
+            //Compute_Test_id(upload_id, "1号尺寸", create_by, create_date, create_org);
+            Compute_Test_id(upload_id, test_standards[0].standard_no, create_by, create_date, create_org);
+
+            List<sqe_cto_test_data> test_datas = _sqe_cto_test_data.Select(a => a.test_id == test.id).OrderBy(a => a.id).ToList();
+
+            //生成统计信息
+            List<sqe_cto_test_avg> test_avgs = _sqe_cto_test_avg.Select(a => a.cto_test_id == test.id).OrderBy(a => a.id).ToList();
+            if (test_avgs != null && test_avgs.Count > 0)
+            {
+                stringBuilder.AppendLine("该id的数据统计已经完成!");
+                return stringBuilder.ToString();
+            }
+            int sample_count = test.sampling_number;
+            for (int i = 0; i <= test_datas.Count - sample_count; i += sample_count)
+            {
+
+            }
+
+            return stringBuilder.ToString();
+        }
+
+        public string Compute_Test_id(int test_id, string standard_no, string create_by, DateTime create_date, string create_org)
+        {
+            StringBuilder stringBuilder = new StringBuilder();
+
+            //查询原始记录
+            List<sqe_cto_test> tests = _sqe_cto_test.Select(a => a.id == test_id).OrderBy(a => a.id).ToList();
+            if (tests == null || tests.Count == 0)
+            {
+                stringBuilder.AppendLine("该id对应的上传数据记录不存在!");
+                return stringBuilder.ToString();
+            }
+            sqe_cto_test test = tests[0];
+
+            List<v_sqe_cto_test_data> test_datas = _v_sqe_cto_test_data.Select(a => a.test_id == test.id && a.standard_no == standard_no && a.data_value != null).OrderBy(a => a.id).ToList();
+            //List<v_sqe_cto_test_data> test_datas = _v_sqe_cto_test_data.Select(a => a.standard_no == standard_no && a.data_value != null).OrderBy(a => a.id).ToList();
+
+            //生成统计信息
+            List<sqe_cto_test_avg> test_avgs = _sqe_cto_test_avg.Select(a => a.cto_test_id == test.id).OrderBy(a => a.id).ToList();
+            if (test_avgs != null && test_avgs.Count > 0)
+            {
+                stringBuilder.AppendLine("该id的数据统计已经完成!");
+                return stringBuilder.ToString();
+            }
+
+            int sample_count = test.sampling_number;
+            double[] data = new double[sample_count];
+            double[] dataAll = new double[test_datas.Count / sample_count * sample_count];
+            double[] dataRange = new double[test_datas.Count / sample_count];
+            for (int i = 0; i <= test_datas.Count - sample_count; i += sample_count)
+            {
+                sqe_cto_test_avg obj = new sqe_cto_test_avg();
+                for (int j = 0; j < sample_count; j++)
+                {
+                    data[j] = (double)test_datas[i + j].data_value.Value;
+                    dataAll[i + j] = data[j];
+                }
+                obj.create_by = create_by;
+                obj.create_date = create_date;
+                obj.create_org = create_org;
+                obj.standard_no = standard_no;
+                obj.sampling_number = sample_count;
+                obj.mean_value = (decimal)data.Average();
+                obj.range_value = (decimal)(data.Max() - data.Min());
+                dataRange[i / sample_count] = (double)obj.range_value;
+                obj.cto_test_id = test_id;
+                test_avgs.Add(obj);
+            }
+
+            decimal a2 = (decimal)GetA2(sample_count);
+            decimal d2 = (decimal)GetD2(sample_count);
+            decimal d3 = (decimal)GetD3(sample_count);
+            decimal d4 = (decimal)GetD4(sample_count);
+
+            //开始计算统计结果
+            sqe_cto_test_statistics model = new sqe_cto_test_statistics();
+            model.create_by = create_by;
+            model.create_date = create_date;
+            model.create_org = create_org;
+            model.cto_test_id = test.id;
+            model.standard_no = standard_no;
+            model.value_count = test_datas.Count;
+            model.standard_min = test_datas[0].standard_min;
+            model.standard_max = test_datas[0].standard_max;
+            model.standard_value = (model.standard_min + model.standard_max) / 2;
+            model.value_sum = (decimal)dataAll.Sum();
+            model.value_avg = (decimal)dataAll.Average();
+            model.value_max = (decimal)dataAll.Max();
+            model.value_min = (decimal)dataAll.Min();
+            model.value_below = dataAll.Count(x => x < (double)model.standard_min);
+            model.value_above = dataAll.Count(x => x > (double)model.standard_max);
+            model.avg_range = (decimal)dataRange.Average();
+            model.value_d2 = d2;
+            model.value_cpu = (model.standard_max - model.value_avg) / (3 * model.avg_range / model.value_d2);
+            model.value_cpl = (model.value_avg - model.standard_min) / (3 * model.avg_range / model.value_d2);
+            model.value_cp = (model.standard_max - model.standard_min) / (6 * model.avg_range / model.value_d2);
+            model.value_cpk = model.value_cpu < model.value_cpl ? model.value_cpu : model.value_cpl;
+            model.value_cr = (decimal)1.0 / model.value_cp;
+            model.value_stdev = (decimal)dataAll.StandardDeviation();
+            model.value_stdevp = (decimal)dataAll.PopulationStandardDeviation();
+            model.value_var = (decimal)dataAll.Variance();
+            model.value_varp = (decimal)dataAll.PopulationVariance();
+            model.value_pp = (model.standard_max - model.standard_min) / (6 * model.value_stdev);
+            model.value_ppu = (model.standard_max - model.value_avg) / (3 * model.value_stdev);
+            model.value_ppl = (model.value_avg - model.standard_min) / (3 * model.value_stdev);
+            model.value_ppk = model.value_ppu < model.value_ppl ? model.value_ppu : model.value_ppl;
+
+            //更新均值方差数据表信息
+            foreach (var item in test_avgs)
+            {
+                item.mean_value_all = model.value_avg;
+                item.range_value_all = model.avg_range;
+                item.value_uclx = item.mean_value_all + item.range_value_all * a2;
+                item.value_lclx = item.mean_value_all - item.range_value_all * a2;
+                item.value_uclr = item.range_value_all * d4;
+                item.value_lclr = item.range_value_all * d3;
+            }
+            _sqe_cto_test_avg.Update(test_avgs);
+            _sqe_cto_test_statistics.Update(model);
+            return stringBuilder.ToString();
+        }
+
+        /// <summary>
+        /// 计算A2系数
+        /// </summary>
+        /// <param name="sample_count"></param>
+        /// <returns></returns>
+        public double GetA2(int sample_count)
+        {
+            switch (sample_count)
+            {
+                case 1:
+                    return 2.659574468;
+                    break;
+                case 2:
+                    return 1.88;
+                    break;
+                case 3:
+                    return 1.023;
+                    break;
+                case 4:
+                    return 0.729;
+                    break;
+                case 5:
+                    return 0.577;
+                    break;
+            }
+            return 1;
+        }
+
+        public double GetD2(int sample_count)
+        {
+            switch (sample_count)
+            {
+                case 1:
+                    return 1.128;
+                    break;
+                case 2:
+                    return 1.128;
+                    break;
+                case 3:
+                    return 1.693;
+                    break;
+                case 4:
+                    return 2.059;
+                    break;
+                case 5:
+                    return 2.326;
+                    break;
+            }
+            return 1;
+        }
+
+        public double GetD4(int sample_count)
+        {
+            switch (sample_count)
+            {
+                case 1:
+                    return 3.267;
+                    break;
+                case 2:
+                    return 3.267;
+                    break;
+                case 3:
+                    return 2.574;
+                    break;
+                case 4:
+                    return 2.282;
+                    break;
+                case 5:
+                    return 2.114;
+                    break;
+            }
+            return 1;
+        }
+
+        public double GetD3(int sample_count)
+        {
+            return 0;
+            //switch (sample_count)
+            //{
+            //    case 1:
+            //        return 1.128;
+            //        break;
+            //    case 2:
+            //        return 1.128;
+            //        break;
+            //    case 3:
+            //        return 1.693;
+            //        break;
+            //    case 4:
+            //        return 2.059;
+            //        break;
+            //    case 5:
+            //        return 2.326;
+            //        break;
+            //}
+            //return 1;
+        }
+
+
+        public string Compute_Test(string startDate, string endDate, string item_no, string item_batch, string org, string standard_no, int sample_count)
+        {
+            try
+            {
+                #region 查询条件
+                // 动态条件
+                var conditions = new List<Expression<Func<v_sqe_cto_test_data, bool>>>();
+                conditions.Add(p => p.data_value != null);
+                if (!string.IsNullOrEmpty(startDate))
+                {
+                    DateTime dateTime;
+                    if (DateTime.TryParse(startDate, out dateTime))
+                    {
+                        // 添加条件1:Name 包含 "searchTerm"
+                        conditions.Add(p => p.create_date >= dateTime);
+                    }
+                }
+                if (!string.IsNullOrEmpty(endDate))
+                {
+                    DateTime dateTime;
+                    if (DateTime.TryParse(endDate, out dateTime))
+                    {
+                        // 添加条件1:Name 包含 "searchTerm"
+                        conditions.Add(p => p.create_date <= dateTime);
+                    }
+                }
+                if (!string.IsNullOrEmpty(item_no))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.item_no == item_no);
+                }
+                if (!string.IsNullOrEmpty(item_batch))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.item_batch == item_batch);
+                }
+                if (!string.IsNullOrEmpty(org))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.create_org == org);
+                }
+                if (!string.IsNullOrEmpty(standard_no))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.standard_no == standard_no);
+                }
+
+                // 组合条件
+                var combinedCondition = PredicateBuilder.New<v_sqe_cto_test_data>();
+                foreach (var condition in conditions)
+                {
+                    combinedCondition = combinedCondition.And(condition);
+                }
+                var query = _v_sqe_cto_test_data.GetDbContext().v_sqe_cto_test_data.AsQueryable();
+
+                // 应用条件
+                if (combinedCondition.Body != null)
+                {
+                    query = query.Where(combinedCondition);
+                }
+                #endregion 查询条件
+
+                // 执行查询
+                List<v_sqe_cto_test_data> test_datas = query.ToList();
+
+                //int sample_count = test_datas != null && test_datas.Count > 0 ? test_datas[0].sampling_count : -1;
+                //if (sample_count == -1)
+                //{
+                //    ResultViewModel resultError = ResultHelper.CreateResult(ResultCode.BusinessError, "您选择数据中的采样数有问题,请核对之后再进行操作!", ResultCode.BusinessError, null);
+                //    return JsonConvert.SerializeObject(resultError);
+                //}
+
+                double[] data = new double[sample_count];
+                double[] dataAll = new double[test_datas.Count / sample_count * sample_count];
+                double[] dataRange = new double[test_datas.Count / sample_count];
+                for (int i = 0; i <= test_datas.Count - sample_count; i += sample_count)
+                {
+                    for (int j = 0; j < sample_count; j++)
+                    {
+                        data[j] = (double)test_datas[i + j].data_value.Value;
+                        dataAll[i + j] = data[j];
+                    }
+                    dataRange[i / sample_count] = data.Max() - data.Min();
+                }
+
+                decimal a2 = (decimal)GetA2(sample_count);
+                decimal d2 = (decimal)GetD2(sample_count);
+                decimal d3 = (decimal)GetD3(sample_count);
+                decimal d4 = (decimal)GetD4(sample_count);
+
+                //开始计算统计结果
+                sqe_cto_test_statistics model = new sqe_cto_test_statistics();
+                model.standard_no = standard_no;
+                model.value_count = test_datas.Count;
+                model.standard_min = test_datas[0].standard_min;
+                model.standard_max = test_datas[0].standard_max;
+                model.standard_value = (model.standard_min + model.standard_max) / 2;
+                model.value_sum = (decimal)dataAll.Sum();
+                model.value_avg = (decimal)dataAll.Average();
+                model.value_max = (decimal)dataAll.Max();
+                model.value_min = (decimal)dataAll.Min();
+                model.value_below = dataAll.Count(x => x < (double)model.standard_min);
+                model.value_above = dataAll.Count(x => x > (double)model.standard_max);
+                model.avg_range = (decimal)dataRange.Average();
+                model.value_d2 = d2;
+                model.value_cpu = (model.standard_max - model.value_avg) / (3 * model.avg_range / model.value_d2);
+                model.value_cpl = (model.value_avg - model.standard_min) / (3 * model.avg_range / model.value_d2);
+                model.value_cp = (model.standard_max - model.standard_min) / (6 * model.avg_range / model.value_d2);
+                model.value_cpk = model.value_cpu < model.value_cpl ? model.value_cpu : model.value_cpl;
+                model.value_cr = (decimal)1.0 / model.value_cp;
+                model.value_stdev = (decimal)dataAll.StandardDeviation();
+                model.value_stdevp = (decimal)dataAll.PopulationStandardDeviation();
+                model.value_var = (decimal)dataAll.Variance();
+                model.value_varp = (decimal)dataAll.PopulationVariance();
+                model.value_pp = (model.standard_max - model.standard_min) / (6 * model.value_stdev);
+                model.value_ppu = (model.standard_max - model.value_avg) / (3 * model.value_stdev);
+                model.value_ppl = (model.value_avg - model.standard_min) / (3 * model.value_stdev);
+                model.value_ppk = model.value_ppu < model.value_ppl ? model.value_ppu : model.value_ppl;
+
+                ResultViewModel result = ResultHelper.CreateResult(ResultCode.Success, model, ResultCode.Success, null);
+                return JsonConvert.SerializeObject(result);
+            }
+            catch (Exception ex)
+            {
+                ResultViewModel resultError = ResultHelper.CreateResult(ResultCode.BusinessError, "您选择数据中的采样数有问题,请核对之后再进行操作!", ResultCode.BusinessError, null);
+                return JsonConvert.SerializeObject(resultError);
+            }
+        }
+
+        /// <summary>
+        /// 依据查询条件,统计工序的不良情况
+        /// </summary>
+        /// <param name="startDate"></param>
+        /// <param name="endDate"></param>
+        /// <param name="item_no"></param>
+        /// <param name="item_batch"></param>
+        /// <param name="org"></param>
+        /// <returns></returns>
+        public string Compute_op_query(string startDate, string endDate, string item_no, string item_batch, string org)
+        {
+            try
+            {
+                #region 查询条件
+                // 动态条件
+                var conditions = new List<Expression<Func<v_sqe_op_data_detail, bool>>>();
+                if (!string.IsNullOrEmpty(startDate))
+                {
+                    DateTime dateTime;
+                    if (DateTime.TryParse(startDate, out dateTime))
+                    {
+                        // 添加条件1:Name 包含 "searchTerm"
+                        conditions.Add(p => p.create_date >= dateTime);
+                    }
+                }
+                if (!string.IsNullOrEmpty(endDate))
+                {
+                    DateTime dateTime;
+                    if (DateTime.TryParse(endDate, out dateTime))
+                    {
+                        // 添加条件1:Name 包含 "searchTerm"
+                        conditions.Add(p => p.create_date <= dateTime);
+                    }
+                }
+                if (!string.IsNullOrEmpty(item_no))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.item_no == item_no);
+                }
+                if (!string.IsNullOrEmpty(item_batch))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.batch_no == item_batch);
+                }
+                if (!string.IsNullOrEmpty(org))
+                {
+                    // 添加条件1:Name 包含 "searchTerm"
+                    conditions.Add(p => p.create_org == org);
+                }
+
+                // 组合条件
+                var combinedCondition = PredicateBuilder.New<v_sqe_op_data_detail>();
+                //此处是所有的条件都and。
+                foreach (var condition in conditions)
+                {
+                    combinedCondition = combinedCondition.And(condition);
+                }
+                var query = _v_sqe_op_data_detail.GetDbContext().v_sqe_op_data_detail.AsQueryable();
+
+                // 应用条件
+                if (conditions.Count > 0)
+                {
+                    query = query.Where(combinedCondition);
+                }
+                #endregion 查询条件
+
+                // 分组统计,此处多个条件进行统计,p.bad_type, p.op_no 
+                var groupBy = query.GroupBy(p => new { p.bad_type, p.op_no })
+                .Select(g => new
+                {
+                    bad_type = g.Key.bad_type,
+                    op_no = g.Key.op_no,
+                    bad_qty = g.Sum(p => p.bad_qty)
+                });
+
+                //增加排序条件,此处多个条件,op_no,bad_type
+                var test_datas = groupBy.OrderBy(p => p.op_no).ThenBy(p => p.bad_type).ToList();
+                ResultViewModel result = ResultHelper.CreateResult(ResultCode.Success, test_datas, ResultCode.Success, null);
+                return JsonConvert.SerializeObject(result);
+
+            }
+            catch (Exception ex)
+            {
+                ResultViewModel resultError = ResultHelper.CreateResult(ResultCode.BusinessError, "您选择的数据在统计中出现问题,请核对之后再进行操作!", ResultCode.BusinessError, null);
+                return JsonConvert.SerializeObject(resultError);
+            }
+            return null;
+        }
     }
 }

+ 5 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_process.cs

@@ -125,5 +125,10 @@ namespace Business.StructuredDB.Sqe
         /// </summary>
         public int delete_flag { get; set; }
 
+        /// <summary>
+        /// 文件上传标志
+        /// </summary>
+        public Int64 file_id { get; set; }
+
     }
 }

+ 6 - 2
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_test.cs

@@ -97,8 +97,7 @@ namespace Business.StructuredDB.Sqe
         /// <summary>
         /// 抽样数
         /// </summary>
-        [DecimalPrecision(18, 5)]
-        public decimal sampling_number { get; set; }
+        public int sampling_number { get; set; }
 
         /// <summary>
         /// 创建日期
@@ -120,5 +119,10 @@ namespace Business.StructuredDB.Sqe
         /// </summary>
         public int delete_flag { get; set; }
 
+        /// <summary>
+        /// 文件上传标志
+        /// </summary>
+        public Int64 file_id { get; set; }
+
     }
 }

+ 105 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_test_avg.cs

@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Business.Core.Attributes;
+using System.IO;
+
+namespace Business.StructuredDB.Sqe
+{
+    /// <summary>
+    /// 产品过程检验记录
+    /// </summary>
+    public class sqe_cto_test_avg
+    {
+
+        /// <summary>
+        /// 流水号主键
+        /// </summary>
+        public Int64 id { get; set; }
+
+        /// <summary>
+        /// CTQ产品特性标识
+        /// </summary>
+        public Int64 cto_test_id { get; set; }
+
+        /// <summary>
+        /// 检验标准编号_尺寸
+        /// </summary>
+        public string standard_no { get; set; }
+
+        /// <summary>
+        /// 抽样数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal sampling_number { get; set; }
+
+        /// <summary>
+        /// 均值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal mean_value { get; set; }
+
+        /// <summary>
+        /// 极差
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal range_value { get; set; }
+
+        /// <summary>
+        /// 总体均值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal mean_value_all { get; set; }
+
+        /// <summary>
+        /// 总体极差
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal range_value_all { get; set; }
+
+        /// <summary>
+        /// UCLx
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_uclx { get; set; }
+
+        /// <summary>
+        /// LCLx
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_lclx { get; set; }
+
+        /// <summary>
+        /// UCLr
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_uclr { get; set; }
+
+        /// <summary>
+        /// LCLr
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_lclr { get; set; }
+
+        /// <summary>
+        /// 创建日期
+        /// </summary>
+        public DateTime create_date { get; set; }
+
+        /// <summary>
+        /// 创建人员
+        /// </summary>
+        public string create_by { get; set; }
+
+        /// <summary>
+        /// 创建部门
+        /// </summary>
+        public string create_org { get; set; }
+
+        /// <summary>
+        /// 删除标志
+        /// </summary>
+        public int delete_flag { get; set; }
+
+    }
+}

+ 199 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_cto_test_statistics.cs

@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Business.Core.Attributes;
+using System.IO;
+
+namespace Business.StructuredDB.Sqe
+{
+    /// <summary>
+    /// 产品过程检验记录
+    /// </summary>
+    public class sqe_cto_test_statistics
+    {
+
+        /// <summary>
+        /// 流水号主键
+        /// </summary>
+        public Int64 id { get; set; }
+
+        /// <summary>
+        /// CTQ产品特性标识
+        /// </summary>
+        public Int64 cto_test_id { get; set; }
+
+        /// <summary>
+        /// 检验标准编号_尺寸
+        /// </summary>
+        public string standard_no { get; set; }
+
+        /// <summary>
+        /// 取值数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_count { get; set; }
+
+        /// <summary>
+        /// 下限
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal standard_min { get; set; }
+
+        /// <summary>
+        /// 标准值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal standard_value { get; set; }
+
+        /// <summary>
+        /// 上限
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal standard_max { get; set; }
+
+        /// <summary>
+        /// 数据总和
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_sum { get; set; }
+
+        /// <summary>
+        /// 样本均值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_avg { get; set; }
+
+        /// <summary>
+        /// 最大值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_max { get; set; }
+
+        /// <summary>
+        /// 最小值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_min { get; set; }
+
+        /// <summary>
+        /// 低于下限数量
+        /// </summary>
+        public int value_below { get; set; }
+
+        /// <summary>
+        /// 高于上限数量
+        /// </summary>
+        public int value_above { get; set; }
+
+        /// <summary>
+        /// 极差平均值
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal avg_range { get; set; }
+
+        /// <summary>
+        /// 估计标准差系数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_d2 { get; set; }
+
+        /// <summary>
+        /// 上限能力指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_cpu { get; set; }
+
+        /// <summary>
+        /// 下限能力指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_cpl { get; set; }
+
+        /// <summary>
+        /// 潜在能力指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_cp { get; set; }
+
+        /// <summary>
+        /// 实际能力指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_cpk { get; set; }
+
+        /// <summary>
+        /// 能力比率
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_cr { get; set; }
+
+        /// <summary>
+        /// 样本标准差
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_stdev { get; set; }
+
+        /// <summary>
+        /// 总体标准差
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_stdevp { get; set; }
+
+        /// <summary>
+        /// 样本方差
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_var { get; set; }
+
+        /// <summary>
+        /// 总体方差
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_varp { get; set; }
+
+        /// <summary>
+        /// 潜在性能指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_pp { get; set; }
+
+        /// <summary>
+        /// 上限性能指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_ppu { get; set; }
+
+        /// <summary>
+        /// 下限性能指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_ppl { get; set; }
+
+        /// <summary>
+        /// 实际性能指数
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal value_ppk { get; set; }
+
+        /// <summary>
+        /// 创建日期
+        /// </summary>
+        public DateTime create_date { get; set; }
+
+        /// <summary>
+        /// 创建人员
+        /// </summary>
+        public string create_by { get; set; }
+
+        /// <summary>
+        /// 创建部门
+        /// </summary>
+        public string create_org { get; set; }
+
+        /// <summary>
+        /// 删除标志
+        /// </summary>
+        public int delete_flag { get; set; }
+
+    }
+}

+ 2 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_fct_data.cs

@@ -35,11 +35,13 @@ namespace Business.StructuredDB.Sqe
         /// <summary>
         /// 测试项值下限
         /// </summary>
+        [DecimalPrecision(18, 5)]
         public decimal lower { get; set; }
 
         /// <summary>
         /// 测试项值上限
         /// </summary>
+        [DecimalPrecision(18, 5)]
         public decimal upper { get; set; }
 
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_file_upload.cs

@@ -25,7 +25,7 @@ namespace Business.StructuredDB.Sqe
         /// <summary>
         /// 生产时间
         /// </summary>
-        public DateTime product_time { get; set; }
+        public DateTime ? product_time { get; set; }
 
         /// <summary>
         /// 生产班次

+ 5 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_fpy.cs

@@ -37,5 +37,10 @@ namespace Business.StructuredDB.Sqe
         /// </summary>
         public int delete_flag { get; set; }
 
+        /// <summary>
+        /// 上传文件标志
+        /// </summary>
+        public Int64 file_id { get; set; }
+
     }
 }

+ 5 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_op.cs

@@ -37,5 +37,10 @@ namespace Business.StructuredDB.Sqe
         /// </summary>
         public int delete_flag { get; set; }
 
+        /// <summary>
+        /// 上传文件标志
+        /// </summary>
+        public Int64 file_id { get; set; }
+
     }
 }

+ 5 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_oqc.cs

@@ -94,5 +94,10 @@ namespace Business.StructuredDB.Sqe
         /// </summary>
         public int delete_flag { get; set; }
 
+        /// <summary>
+        /// 上传文件标志
+        /// </summary>
+        public Int64 file_id { get; set; }
+
     }
 }

+ 51 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/sqe_transfer.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Business.Core.Attributes;
+using System.IO;
+
+namespace Business.StructuredDB.Sqe
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class sqe_transfer
+    {
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string filePath { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string fileName { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string uploadType { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string createBy { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string createOrg { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime createTime { get; set; }
+
+    }
+}

+ 199 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/v_sqe_cto_test_data.cs

@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Business.Core.Attributes;
+using System.IO;
+
+namespace Business.StructuredDB.Sqe
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class v_sqe_cto_test_data
+    {
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 test_id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 standard_id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string data_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string data_time { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal? data_value { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string data_result { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string standard_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int sampling_count { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string is_associated_size { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal standard_value { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal delta_up { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal delta_down { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal standard_max { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal standard_min { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string supp_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime product_time { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string shift_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string item_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string item_name { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string material_batch { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal material_used { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string item_batch { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal item_qty { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string op_pre { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string op_pre_batch { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string op_current { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string op_batch { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string device_name { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string device_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int sampling_number { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime create_date { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string create_by { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string create_org { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int delete_flag { get; set; }
+
+    }
+}

+ 139 - 0
MicroServices/Business/Business.Domain/StructuredDB/Sqe/v_sqe_op_data_detail.cs

@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Business.Core.Attributes;
+using System.IO;
+
+namespace Business.StructuredDB.Sqe
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class v_sqe_op_data_detail
+    {
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 op_data_id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string bad_type { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal bad_qty { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal percent_bad_all { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal percent_bad { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 file_id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Int64 op_id { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string supp_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime op_time { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string item_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string item_name { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string batch_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string op_no { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal qty_all { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal qty_ok { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal qty_error { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal percent_ok { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [DecimalPrecision(18, 5)]
+        public decimal percent_error { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime create_date { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string create_by { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string create_org { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int delete_flag { get; set; }
+
+    }
+}

+ 32 - 0
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs

@@ -545,6 +545,15 @@ namespace Business.EntityFrameworkCore
 
             });
 
+            builder.Entity<sqe_cto_test_avg>(b =>
+            {
+                b.ToTable("sqe_cto_test_avg");
+                b.HasNoKey();
+                b.Property(b => b.create_date).HasDefaultValue(DateTime.Now);
+                b.ConfigureByConvention();
+
+            });
+
             builder.Entity<sqe_cto_test_data>(b =>
             {
                 b.ToTable("sqe_cto_test_data");
@@ -563,6 +572,15 @@ namespace Business.EntityFrameworkCore
 
             });
 
+            builder.Entity<sqe_cto_test_statistics>(b =>
+            {
+                b.ToTable("sqe_cto_test_statistics");
+                b.HasNoKey();
+                b.Property(b => b.create_date).HasDefaultValue(DateTime.Now);
+                b.ConfigureByConvention();
+
+            });
+
             builder.Entity<sqe_file_data>(b =>
             {
                 b.ToTable("sqe_file_data");
@@ -670,6 +688,20 @@ namespace Business.EntityFrameworkCore
                 b.ConfigureByConvention();
 
             });
+
+            builder.Entity<v_sqe_cto_test_data>(b =>
+            {
+                b.ToView("v_sqe_cto_test_data");
+                b.HasNoKey();
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<v_sqe_op_data_detail>(b =>
+            {
+                b.ToView("v_sqe_op_data_detail");
+                b.HasNoKey();
+                b.ConfigureByConvention();
+            });
         }
     }
 }

+ 4 - 1
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/Sqe/BusinessSqeDbContext.cs

@@ -16,8 +16,10 @@ namespace Business.EntityFrameworkCore
         public DbSet<sqe_cto_process_data> sqe_cto_process_data { get; set; }
         public DbSet<sqe_cto_process_standard> sqe_cto_process_standard { get; set; }
         public DbSet<sqe_cto_test> sqe_cto_test { get; set; }
+        public DbSet<sqe_cto_test_avg> sqe_cto_test_avg { get; set; }
         public DbSet<sqe_cto_test_data> sqe_cto_test_data { get; set; }
         public DbSet<sqe_cto_test_standard> sqe_cto_test_standard { get; set; }
+        public DbSet<sqe_cto_test_statistics> sqe_cto_test_statistics { get; set; }
         public DbSet<sqe_file_data> sqe_file_data { get; set; }
         public DbSet<sqe_file_upload> sqe_file_upload { get; set; }
         public DbSet<sqe_oqc> sqe_oqc { get; set; }
@@ -30,7 +32,8 @@ namespace Business.EntityFrameworkCore
         public DbSet<sqe_op_data_detail> sqe_op_data_detail { get; set; }
         public DbSet<sqe_fct> sqe_fct { get; set; }
         public DbSet<sqe_fct_data> sqe_fct_data { get; set; }
-
+        public DbSet<v_sqe_cto_test_data> v_sqe_cto_test_data { get; set; }
+        public DbSet<v_sqe_op_data_detail> v_sqe_op_data_detail { get; set; }
 
         #endregion SqeÊý¾Ý·ÃÎÊ
 

+ 3 - 1
MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/ISqeRepository.cs

@@ -1,4 +1,5 @@
-using Microsoft.EntityFrameworkCore.ChangeTracking;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -14,6 +15,7 @@ namespace Business.EntityFrameworkCore.SqlRepositories
         public void CommitTransaction();
         public void Rollback();
         public void Dispose();
+        public BusinessSqeDbContext GetDbContext();
 
         int Insert(T entity);
         int Insert(List<T> entitylist);

+ 23 - 19
MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/SqeRepository.cs

@@ -17,7 +17,7 @@ using Microsoft.EntityFrameworkCore.Storage;
 
 namespace Business.EntityFrameworkCore.SqlRepositories
 {
-    public class SqeRepository<T>: ISqeRepository<T> where T : class, new()
+    public class SqeRepository<T> : ISqeRepository<T> where T : class, new()
     {
         /// <summary>
         /// 数据库操作对象
@@ -74,40 +74,44 @@ namespace Business.EntityFrameworkCore.SqlRepositories
                 _transaction = null;
             }
         }
+        public BusinessSqeDbContext GetDbContext()
+        {
+            return _dbContext;
+        }
 
-        public  int Insert(T entity)
+        public int Insert(T entity)
         {
             _dbContext.Set<T>().Add(entity);
-            return  _dbContext.SaveChanges();
+            return _dbContext.SaveChanges();
         }
 
         public int Insert(List<T> entitylist)
         {
-             _dbContext.Set<T>().AddRange(entitylist);
-            return  _dbContext.SaveChanges();
+            _dbContext.Set<T>().AddRange(entitylist);
+            return _dbContext.SaveChanges();
         }
 
-        public  int Update(T entity)
+        public int Update(T entity)
         {
             _dbContext.Set<T>().Update(entity);
-           return _dbContext.SaveChanges();
+            return _dbContext.SaveChanges();
         }
-        public  int Update(List<T> entitylist)
+        public int Update(List<T> entitylist)
         {
             _dbContext.Set<T>().UpdateRange(entitylist);
-           return  _dbContext.SaveChanges();
+            return _dbContext.SaveChanges();
         }
 
         public int Update(Expression<Func<T, bool>> whereLambda, Expression<Func<T, T>> entity)
         {
             _dbContext.Set<T>().Where(whereLambda).BatchUpdate(entity);
-            return  _dbContext.SaveChanges();
+            return _dbContext.SaveChanges();
         }
 
-        public  int Delete(Expression<Func<T, bool>> whereLambda)
+        public int Delete(Expression<Func<T, bool>> whereLambda)
         {
             _dbContext.Set<T>().Where(whereLambda).BatchDelete();
-            return  _dbContext.SaveChanges();
+            return _dbContext.SaveChanges();
         }
 
         public int Delete(List<T> entitylist)
@@ -116,17 +120,17 @@ namespace Business.EntityFrameworkCore.SqlRepositories
             return _dbContext.SaveChanges();
         }
 
-        public  bool IsExist(Expression<Func<T, bool>> whereLambda)
+        public bool IsExist(Expression<Func<T, bool>> whereLambda)
         {
-            return  _dbContext.Set<T>().Any(whereLambda);
+            return _dbContext.Set<T>().Any(whereLambda);
         }
 
-        public  List<T> Select()
+        public List<T> Select()
         {
-            return  _dbContext.Set<T>().ToList();
+            return _dbContext.Set<T>().ToList();
         }
 
-        public  List<T> Select(Expression<Func<T, bool>> whereLambda)
+        public List<T> Select(Expression<Func<T, bool>> whereLambda)
         {
             return _dbContext.Set<T>().Where(whereLambda).ToList();
         }
@@ -137,12 +141,12 @@ namespace Business.EntityFrameworkCore.SqlRepositories
 
             if (isAsc)
             {
-                var entities =  _dbContext.Set<T>().Where(whereLambda)
+                var entities = _dbContext.Set<T>().Where(whereLambda)
                                       .OrderBy<T, S>(orderByLambda)
                                       .Skip(pageSize * (pageIndex - 1))
                                       .Take(pageSize).ToList();
 
-                return  new Tuple<List<T>, int>(entities, total);
+                return new Tuple<List<T>, int>(entities, total);
             }
             else
             {

+ 36 - 0
MicroServices/Business/Business.HttpApi/Controllers/SqeController.cs

@@ -130,5 +130,41 @@ namespace Business.Controllers
                 return json.ToString();
             }
         }
+
+
+        [HttpGet]
+        [Route("compute_test_id")]
+        public string Compute_test_id(int file_id)
+        {
+            String s = _SqeExcelService.Compute_Test(file_id, "测试用户", DateTime.Now, "测试组织");
+            return s;
+        }
+
+        [HttpGet]
+        [Route("compute_test_query")]
+        public string Compute_test_query(string startDate, string endDate, string item_no, string item_batch, string org, string standard_no, int sample_count)
+        {
+            String s = _SqeExcelService.Compute_Test(startDate, endDate, item_no, item_batch, org, standard_no, sample_count);
+            return s;
+        }
+
+        /// <summary>
+        /// 依据查询条件,统计工序的不良情况
+        /// </summary>
+        /// <param name="startDate"></param>
+        /// <param name="endDate"></param>
+        /// <param name="item_no"></param>
+        /// <param name="item_batch"></param>
+        /// <param name="org"></param>
+        /// <returns></returns>
+        [HttpGet]
+        [Route("compute_op_query")]
+        public string Compute_op_query(string startDate, string endDate, string item_no, string item_batch, string org)
+        {
+            String s = _SqeExcelService.Compute_op_query(startDate, endDate, item_no, item_batch, org);
+            return s;
+        }
+
+
     }
 }

+ 6 - 0
MicroServices/Business/QuartzSettings/logs/logs.txt

@@ -4312,3 +4312,9 @@
 {"TaskName":"长周期物料PR","GroupName":"systemquartzjob","BeginDate":"2025-07-09T16:37:57.0800743+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
 {"TaskName":"TestTimeOut","GroupName":"systemquartzjob","BeginDate":"2025-07-09T16:37:57.0846448+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
 {"TaskName":"BOM预处理自动任务","GroupName":"BOM预处理自动任务","BeginDate":"2025-07-09T16:37:57.0870444+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
+{"TaskName":"定时同步WMS物料订单等基础数据到MySQL","GroupName":"systemquartzjob","BeginDate":"2025-07-14T13:37:55.0550073+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
+{"TaskName":"定时创建NLog日志按月分表","GroupName":"systemquartzjob","BeginDate":"2025-07-14T13:37:55.0916896+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
+{"TaskName":"定时同步MySQL基础数据到MongoDB","GroupName":"systemquartzjob","BeginDate":"2025-07-14T13:37:55.0946605+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
+{"TaskName":"长周期物料PR","GroupName":"systemquartzjob","BeginDate":"2025-07-14T13:37:55.0965272+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
+{"TaskName":"TestTimeOut","GroupName":"systemquartzjob","BeginDate":"2025-07-14T13:37:55.1021642+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}
+{"TaskName":"BOM预处理自动任务","GroupName":"BOM预处理自动任务","BeginDate":"2025-07-14T13:37:55.1041741+08:00","EndDate":null,"Msg":"任务初始化启动成功:6","id":0,"timeflag":null,"changetime":null}