lixiaojun
2022-09-02 d5a3d08601fa59498edc092cec23c7ca166a0d15
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
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>
    /// EtaAnalyDeviation
    /// </summary>
    [Route("Eta/Analy/Deviation")]
    [ApiDescriptionSettings("Eta", Name = "能效偏差分析", Order = 900)]
    public class EtaAnalyDeviation_Controller : IDynamicApiController
    {
        /// <summary>
        /// 通过 PipeLineID 获取某日偏差内容记录
        /// </summary>
        [Route("GetContentByPipeLineIDOfDay@V1.0")]
        [HttpGet]
        public List<EtaDeviationDayContent> GetContentByPipeLineIDOfDay
            (
                [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
                long CorpID,
                [Required, Range(1, long.MaxValue, ErrorMessage = "PipeLineID 必须大于0")]
                long PipeLineID,
                [Required]
                DateTime Day
            )
        {
            var pipeLine = new Service.PipeLine().GetByID(CorpID, PipeLineID);
            if (pipeLine == null)
            {
                throw new Exception("未检索到管路信息");
            }
            if (pipeLine.Catalog != IStation.PipeLine.EnginePump)
            {
                throw new Exception("未检索到机泵管路信息");
            }
            var bindingList = new Service.PipeLineBinding().GetUseByPipeLineID(CorpID, PipeLineID);
            if (bindingList == null || bindingList.Count < 1)
            {
                throw new Exception("未设置管路绑定");
            }
            bindingList = bindingList.Where(x => x.BindingType == IStation.ObjectType.Product).ToList();
            if (bindingList.Count < 1)
            {
                throw new Exception("未绑定设备信息");
            }
            var productList = new Service.Product().GetByIds(CorpID, bindingList.Select(x => x.BindingID).ToList());
            if (productList == null || productList.Count < 1)
            {
                throw new Exception("未检索到设备信息");
            }
            var product = productList.Find(x => x.Catalog == IStation.Product.Catalog_JiBeng);
            if (product == null)
            {
                throw new Exception("未检索到机泵信息");
            }
            var pump = new Service.Product().GetChildPumpByEnginePumpID(product.CorpID, product.ID);
            if (pump == null)
            {
                throw new Exception("未检索到泵信息");
            }
            var curve = new Service.PumpCurveExMapping().GetDefaultWorkingByPumpID(pump.CorpID, pump.ID);
            if (curve == null)
            {
                throw new Exception("未检索到泵曲线信息");
            }
 
            var vmList = new List<EtaDeviationDayContent>();
            var recordList = new Service.EtaSingleRealRecord().GetRunByObjectOfDay(CorpID, ObjectType.PipeLine, PipeLineID, Day);
            recordList = recordList?.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
            if (recordList != null && recordList.Count > 0)
            {
                foreach (var record in recordList)
                {
                    var vm = new EtaDeviationDayContent();
                    vm.Time = record.DataTime.ToString("HH:mm:ss");
                    vm.HZr = record.HZa;//新增字段 nsx
 
                    vm.Qr = Math.Round(record.Qa.Value, 2);
                    vm.Hr = Math.Round(record.Ha.Value, 2);
                    vm.Er = Math.Round(record.Ea.Value, 2);
                    vm.Pr = Math.Round(record.Pa.Value, 2);
 
                    if (record.HZa < 49 && record.HZa > 10)
                    {
                        //得到相似换算值
                        double ratio = 50 / record.HZa;
                        vm.Q = Math.Round(record.Qa.Value * ratio, 2);
                        vm.H = Math.Round(record.Ha.Value * ratio * ratio, 2);
                        vm.E = Math.Round(record.Ea.Value, 2);
                        vm.P = Math.Round(record.Pa.Value * ratio * ratio * ratio, 2);
                    }
                    else
                    {
                        vm.Q = Math.Round(record.Qa.Value, 2);
                        vm.H = Math.Round(record.Ha.Value, 2);
                        vm.E = Math.Round(record.Ea.Value, 2);
                        vm.P = Math.Round(record.Pa.Value, 2);
                    }
 
                    double h_rated = curve.CurveInfo.CurveQH.GetFitPointY(vm.Q);
                    double eta_rated = curve.CurveInfo.CurveQE.GetFitPointY(vm.Q);
                    double power_rated = curve.CurveInfo.CurveQP.GetFitPointY(vm.Q);
 
                    vm.DeviateH = (vm.H - h_rated).ToString("0.0");//扬程偏差
                    vm.DeviateE = (vm.E - eta_rated).ToString("0.0");//效率偏差
                    vm.DeviateP = (vm.P - power_rated).ToString("0.0");//功率偏差
 
                    vm.DeviateRatioH = ((vm.H - h_rated) * 100 / h_rated).ToString("0.0");//扬程偏差率
                    vm.DeviateRatioP = ((vm.P - power_rated) * 100 / power_rated).ToString("0.0");//功率偏差率
                    vmList.Add(vm);
                }
 
            }
 
            return vmList;
        }
 
    }
}