From e5a570db2036a6b155c2ddc289b42bd050b9ad3c Mon Sep 17 00:00:00 2001
From: lx <ex_lixiang17@cosl.com.cn>
Date: 星期一, 24 十一月 2025 13:49:16 +0800
Subject: [PATCH] update 1.4

---
 ErrorAnalysis.Service/COMergeCalcService.cs |   76 ++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/ErrorAnalysis.Service/COMergeCalcService.cs b/ErrorAnalysis.Service/COMergeCalcService.cs
index 42bd463..beda9e4 100644
--- a/ErrorAnalysis.Service/COMergeCalcService.cs
+++ b/ErrorAnalysis.Service/COMergeCalcService.cs
@@ -26,8 +26,9 @@
 
         //const double _coef = 1e8 * 2.54 * 2.54 * 4 * 6 * 2 * 11 * 77 * 0.2 / 0.6;
 
-        private static (double, double) GetFarInterplolateResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting)
+        private static (double, double) GetFarInterplolateResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting, int countStart, int countEnd)
         {
+            var countLen = countEnd - countStart + 1;
             var cWinLength = _cWinEndIndex - _cWinStartIndex + 1;
             var oWinLength = _oWinEndIndex - _oWinStartIndex + 1;
             var oilLine = RepositoryInstance.Instance.COFarResultRepository?.GetCOFarResult(modelId, (int)porosity, 0);
@@ -37,14 +38,14 @@
             var oilLineValArr = oilLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
             var waterLineValArr = waterLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
 
-            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
-            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
+            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
+            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
 
             var oilLineC = 36d / 160d * oilLineCR * yieldCounting / speed * depth * 0.0762d;
             var oilLineO = 36d / 160d * oilLineOR * yieldCounting / speed * depth * 0.0762d;
 
-            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
-            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
+            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
+            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
             var waterLineC = 36d / 160d * waterLineCR * yieldCounting / speed * depth * 0.0762d;
             var waterLineO = 36d / 160d * waterLineOR * yieldCounting / speed * depth * 0.0762d;
 
@@ -67,8 +68,9 @@
             return (cRes, oRes);
         }
 
-        private static (double, double) GetNearInterplolateResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting)
+        private static (double, double) GetNearInterplolateResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting, int countStart, int countEnd)
         {
+            var countLen = countEnd - countStart + 1;
             var cWinLength = _cWinEndIndex - _cWinStartIndex + 1;
             var oWinLength = _oWinEndIndex - _oWinStartIndex + 1;
             var oilLine = RepositoryInstance.Instance.CONearResultRepository?.GetCONearResult(modelId, (int)porosity, 0);
@@ -78,13 +80,13 @@
             var oilLineValArr = oilLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
             var waterLineValArr = waterLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
 
-            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
-            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
+            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
+            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
             var oilLineC = (36d / 160d) * oilLineCR * yieldCounting / speed * depth * 0.0762d;
             var oilLineO = (36d / 160d) * oilLineOR * yieldCounting / speed * depth * 0.0762d;
 
-            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
-            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
+            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
+            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
             var waterLineC = (36d / 160d) * waterLineCR * yieldCounting / speed * depth * 0.0762d;
             var waterLineO = (36d / 160d) * waterLineOR * yieldCounting / speed * depth * 0.0762d;
 
@@ -119,7 +121,7 @@
         /// <param name="depth">娣卞害</param>
         /// <returns>纰冲拰姘у��</returns>
         /// <exception cref="InvalidDataException">瀛旈殭搴﹁秴杩囪寖鍥�</exception>
-        public static (double, double) GetFarMergeCOResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting)
+        public static (double, double) GetFarMergeCOResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting, int countStart, int countEnd)
         {
             if (porosity > 40)
                 throw new InvalidDataException("Porosity value out of range!");
@@ -127,15 +129,15 @@
             (double, double) result = (0, 0);
             if (porosity % 5 == 0)
             {
-                result = GetFarInterplolateResult(modelId, porosity, sw, speed, depth, yieldCounting);
+                result = GetFarInterplolateResult(modelId, porosity, sw, speed, depth, yieldCounting, countStart, countEnd);
             }
             else
             {
                 var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
-                var ceilingResult = GetFarInterplolateResult(modelId, ceilingPorosity, sw, speed, depth, yieldCounting);
+                var ceilingResult = GetFarInterplolateResult(modelId, ceilingPorosity, sw, speed, depth, yieldCounting, countStart, countEnd);
 
                 var floorPorosity = Math.Floor(porosity / 5) * 5;
-                var floorResult = GetFarInterplolateResult(modelId, floorPorosity, sw, speed, depth, yieldCounting);
+                var floorResult = GetFarInterplolateResult(modelId, floorPorosity, sw, speed, depth, yieldCounting, countStart, countEnd);
 
                 result.Item1 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item1, ceilingPorosity, ceilingResult.Item1);
                 result.Item2 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item2, ceilingPorosity, ceilingResult.Item2);
@@ -155,7 +157,7 @@
         /// <param name="depth">娣卞害</param>
         /// <returns>纰虫垨姘у��</returns>
         /// <exception cref="InvalidDataException">瀛旈殭搴﹁秴杩囪寖鍥�</exception>
-        public static (double, double) GetNearMergeCOResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting)
+        public static (double, double) GetNearMergeCOResult(string modelId, double porosity, double sw, double speed, double depth, double yieldCounting, int countStart, int countEnd)
         {
             if (porosity > 40)
                 throw new InvalidDataException("Porosity value out of range!");
@@ -163,15 +165,15 @@
             (double, double) result = (0, 0);
             if (porosity % 5 == 0)
             {
-                result = GetNearInterplolateResult(modelId, porosity, sw, speed, depth, yieldCounting);
+                result = GetNearInterplolateResult(modelId, porosity, sw, speed, depth, yieldCounting, countStart, countEnd);
             }
             else
             {
                 var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
-                var ceilingResult = GetNearInterplolateResult(modelId, ceilingPorosity, sw, speed, depth, yieldCounting);
+                var ceilingResult = GetNearInterplolateResult(modelId, ceilingPorosity, sw, speed, depth, yieldCounting, countStart, countEnd);
 
                 var floorPorosity = Math.Floor(porosity / 5) * 5;
-                var floorResult = GetNearInterplolateResult(modelId, floorPorosity, sw, speed, depth, yieldCounting);
+                var floorResult = GetNearInterplolateResult(modelId, floorPorosity, sw, speed, depth, yieldCounting, countStart, countEnd);
 
                 result.Item1 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item1, ceilingPorosity, ceilingResult.Item1);
                 result.Item2 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item2, ceilingPorosity, ceilingResult.Item2);
@@ -297,8 +299,9 @@
             return result;
         }
 
-        public static (double, double) GetFarCROR(string modelId, double porosity, double sw)
+        public static (double, double) GetFarCROR(string modelId, double porosity, double sw, int countStart, int countEnd)
         {
+            int countLen = countEnd - countStart + 1;
             var cWinLength = _cWinEndIndex - _cWinStartIndex + 1;
             var oWinLength = _oWinEndIndex - _oWinStartIndex + 1;
             var oilLine = RepositoryInstance.Instance.COFarResultRepository?.GetCOFarResult(modelId, (int)porosity, 0);
@@ -308,11 +311,11 @@
             var oilLineValArr = oilLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
             var waterLineValArr = waterLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
 
-            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
-            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
+            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
+            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
 
-            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
-            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
+            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
+            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
 
             double cRes = 0, oRes = 0;
             if (sw == 0)
@@ -333,8 +336,9 @@
             return (cRes, oRes);
         }
 
-        public static (double, double) GetNearCROR(string modelId, double porosity, double sw)
+        public static (double, double) GetNearCROR(string modelId, double porosity, double sw, int countStart, int countEnd)
         {
+            int countLen = countEnd - countStart + 1;
             var cWinLength = _cWinEndIndex - _cWinStartIndex + 1;
             var oWinLength = _oWinEndIndex - _oWinStartIndex + 1;
             var oilLine = RepositoryInstance.Instance.CONearResultRepository?.GetCONearResult(modelId, (int)porosity, 0);
@@ -344,11 +348,11 @@
             var oilLineValArr = oilLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
             var waterLineValArr = waterLine.CInelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
 
-            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
-            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(17).Take(237).Sum();
+            var oilLineCR = oilLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
+            var oilLineOR = oilLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / oilLineValArr.Skip(countStart).Take(countLen).Sum();
 
-            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
-            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(17).Take(237).Sum();
+            var waterLineCR = waterLineValArr.Skip(_cWinStartIndex - 1).Take(cWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
+            var waterLineOR = waterLineValArr.Skip(_oWinStartIndex - 1).Take(oWinLength).Sum() / waterLineValArr.Skip(countStart).Take(countLen).Sum();
 
             double crRes = 0, orRes = 0;
             if (sw == 0)
@@ -369,7 +373,7 @@
             return (crRes, orRes);
         }
 
-        public static (double, double) GetFarCOORResult(string modelId, double porosity, double sw)
+        public static (double, double) GetFarCOORResult(string modelId, double porosity, double sw, int countStart, int countEnd)
         {
             if (porosity > 40)
                 throw new InvalidDataException("Porosity value out of range!");
@@ -377,15 +381,15 @@
             (double, double) result = (0, 0);
             if (porosity % 5 == 0)
             {
-                result = GetFarCROR(modelId, porosity, sw);
+                result = GetFarCROR(modelId, porosity, sw, countStart, countEnd);
             }
             else
             {
                 var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
-                var ceilingResult = GetFarCROR(modelId, ceilingPorosity, sw);
+                var ceilingResult = GetFarCROR(modelId, ceilingPorosity, sw, countStart, countEnd);
 
                 var floorPorosity = Math.Floor(porosity / 5) * 5;
-                var floorResult = GetFarCROR(modelId, floorPorosity, sw);
+                var floorResult = GetFarCROR(modelId, floorPorosity, sw, countStart, countEnd);
 
                 result.Item1 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item1, ceilingPorosity, ceilingResult.Item1);
                 result.Item2 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item2, ceilingPorosity, ceilingResult.Item2);
@@ -393,7 +397,7 @@
             return result;
         }
 
-        public static (double, double) GetNearCOORResult(string modelId, double porosity, double sw)
+        public static (double, double) GetNearCOORResult(string modelId, double porosity, double sw, int countStart, int countEnd)
         {
             if (porosity > 40)
                 throw new InvalidDataException("Porosity value out of range!");
@@ -401,15 +405,15 @@
             (double, double) result = (0, 0);
             if (porosity % 5 == 0)
             {
-                result = GetNearCROR(modelId, porosity, sw);
+                result = GetNearCROR(modelId, porosity, sw, countStart, countEnd);
             }
             else
             {
                 var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
-                var ceilingResult = GetNearCROR(modelId, ceilingPorosity, sw);
+                var ceilingResult = GetNearCROR(modelId, ceilingPorosity, sw, countStart, countEnd);
 
                 var floorPorosity = Math.Floor(porosity / 5) * 5;
-                var floorResult = GetNearCROR(modelId, floorPorosity, sw);
+                var floorResult = GetNearCROR(modelId, floorPorosity, sw, countStart, countEnd);
 
                 result.Item1 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item1, ceilingPorosity, ceilingResult.Item1);
                 result.Item2 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item2, ceilingPorosity, ceilingResult.Item2);

--
Gitblit v1.9.3