lixiaojun
2023-03-21 c6c912c9a0b1235805dea4fbb471e26a7f13a47d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
 
 
namespace IStation.Application
{
    /// <summary>
    /// PumpCurve
    /// </summary>
    [Route("Product/ParallelCurve")]
    [NonUnify]
    [ApiDescriptionSettings("Product", Name = "²¢ÁªÇúÏß", Order = 401)]
    public class ParallelCurve_Controller : IDynamicApiController
    {
 
        private readonly Service.PumpCurve _service = new Service.PumpCurve();
 
 
        /// <summary>
        /// ¼ÆËã¹Ü·²¢ÁªÇúÏßÍØÕ¹£¨°üº¬µ¥±ÃÇúÏߣ©
        /// </summary>
        [Route("CalculatePipeLineParallelEx")]
        [HttpPost]
        public IStation.Dto.ApiResult CalculatePipeLineParallelEx(ViewModel.PipeLineParallelCurveRequest model)
        {
            //if (model == null)
            //{
               return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Alert, "´úÂëÕûÀíÖÐ");
            //}
            //if (model.CorpID < 1)
            //{
            //    return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Alert, "CorpID ²ÎÊý´íÎó");
            //}
            //if (model.Items == null || model.Items.Count < 1)
            //{
            //    return new IStation.Dto.ApiResult (IStation.Dto.ApiResultCode.Alert, "²¢Áª²ÎÊý´íÎó");
            //}
 
            //var service_pipe = new Service.PipeLine();
            //var service_binding = new Service.PipeLineBinding();
            //var service_product = new Service.Product();
            //var service_curve = new Service.PumpCurveExMapping();
            //var vm_list = new List<ViewModel.ParallelCurveEx>();
 
            //var curve_qh_list = new List<Model.CurveExpress>();
            //var curve_qp_list = new List<Model.CurveExpress>();
            //var h_min = double.MinValue;
            //var h_max = double.MaxValue;
 
            //foreach (var item in model.Items)
            //{
            //    var pipe = service_pipe.GetByID(model.CorpID, item.PipeLineID);
            //    if (pipe == null)
            //        continue;
            //    var binding_list = service_binding.GetUseByPipeLineID(model.CorpID, item.PipeLineID);
            //    if (binding_list == null || binding_list.Count < 1)
            //        continue;
            //    var binding = binding_list.Find(x => x.ObjectType == ObjectType.Product_É豸);
            //    if (binding == null)
            //        continue;
            //    var pump = service_product.GetChildPumpByEnginePumpID(binding.CorpID, binding.ObjectID);
            //    if (pump == null)
            //        continue;
            //    var curve = service_curve.GetDefaultWorkingByPumpID(pump.CorpID, pump.ID);
            //    if (curve == null)
            //        continue;
 
            //    if (item.HZ > 49.5)
            //    {
            //        if (curve.CurveInfo != null && curve.CurveInfo.CurveQH != null)
            //        {
            //            curve_qh_list.Add(curve.CurveInfo.CurveQH);
            //            if (curve.CurveInfo.CurveQP != null)
            //            {
            //                curve_qp_list.Add(curve.CurveInfo.CurveQP);
            //            }
            //        }
            //    }
            //    else
            //    {
            //        var curve_qh = curve.CalcuCurveQhByHz(item.HZ);
            //        if (curve_qh != null)
            //        {
            //            curve_qh_list.Add(curve_qh);
            //            var curve_qp = curve.CalcuCurveQpByHz(item.HZ);
            //            if (curve_qp != null)
            //            {
            //                curve_qp_list.Add(curve_qp);
            //            }
            //        }
            //    }
 
            //    var curve_qh_last = curve_qh_list.LastOrDefault();
            //    if (curve_qh_last != null)
            //    {
            //        var curve_qh_first_point = curve_qh_last.GetFirstFitPoint();
            //        h_max = Math.Min(h_max, curve_qh_first_point.Y);
            //        var curve_qh_last_point = curve_qh_last.GetLastFitPoint();
            //        h_min = Math.Max(h_min, curve_qh_last_point.Y);
            //    }
            //    var vm_parallel_curve = new ViewModel.ParallelCurveEx();
            //    vm_parallel_curve.Type = 0;
            //    vm_parallel_curve.Name = pipe.Name;
            //    vm_parallel_curve.PointQH = curve_qh_list.LastOrDefault()?.GetFitPoints(20)?.Select(x => new ViewModel.CurvePoint(x)).ToList();
            //    vm_parallel_curve.PointQP = curve_qp_list.LastOrDefault()?.GetFitPoints(20)?.Select(x => new ViewModel.CurvePoint(x)).ToList();
            //    vm_list.Add(vm_parallel_curve);
            //}
 
            //if (curve_qh_list.Count < 2)
            //{
            //    return new Result(Code.Alert, "NULL1");
            //}
            //if (h_max < h_min)
            //{
            //    return new Result(Code.Alert, "NULL2");
            //}
 
            //double space_h = (h_max - h_min) / 19;
            //var points_qh_parallel = new List<Model.CurvePoint>();
            //var points_qp_parallel = new List<Model.CurvePoint>();
 
            //for (var h = h_min; h <= h_max; h = h + space_h)
            //{
            //    double total_flow = 0;
            //    double total_power = 0;
 
            //    for (int j = 0; j < curve_qh_list.Count; j++)
            //    {
            //        var curve_qh = curve_qh_list[j];
            //        var curve_qp = curve_qp_list[j];
            //        var pts = Model.FitCurveHelper.GetInterPointX(curve_qh, h);
            //        if (pts != null && pts.Count > 0)
            //        {
            //            var q = pts.Last().X;
            //            total_flow += q;
            //            total_power += curve_qp.GetFitPointY(q);
            //        }
            //    }
            //    points_qh_parallel.Add(new Model.CurvePoint(total_flow, h));
            //    points_qp_parallel.Add(new Model.CurvePoint(total_flow, total_power));
            //}
 
            //var vm = new ViewModel.ParallelCurveEx();
            //vm.Type = 1;
            //vm.Name = "²¢ÁªÇúÏß";
            //vm.PointQH = Model.FitCurveHelper.GetFitPoints(points_qh_parallel, 20)?.Select(x => new ViewModel.CurvePoint(x)).ToList();
            //vm.PointQP = Model.FitCurveHelper.GetFitPoints(points_qp_parallel, 20)?.Select(x => new ViewModel.CurvePoint(x)).ToList();
            //vm_list.Insert(0, vm);
            //return new Result<List<ViewModel.ParallelCurveEx>>(vm_list);
        }
 
 
 
 
 
    }
}