lixiaojun
2022-08-22 cd280a9457eda95433896e3e9e3aa5164bdd64a0
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
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Service
{
    public partial class PumpCurveExMapping
    {
        private Entity.PumpCurve Model2CurveEntity(Model.PumpCurveExMapping model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.PumpCurveExMapping, Entity.PumpCurve>()
            .ForMember(d => d.CoordParas, opt => opt.MapFrom(src => src.CoordParas == null ? string.Empty : src.CoordParas.ToJson()))
            .ForMember(d => d.CurveInfo, opt => opt.MapFrom(src => src.CurveInfo == null ? string.Empty : src.CurveInfo.ToDsString()))
            .ForMember(d => d.PointInfo, opt => opt.MapFrom(src => src.PointInfo == null ? string.Empty : src.PointInfo.ToDsString()))
            ).CreateMapper();
            var entity = mapper.Map<Model.PumpCurveExMapping, Entity.PumpCurve>(model);
            return entity;
        }
 
        private Entity.PumpCurveMapping Model2MappingEntity(Model.PumpCurveExMapping model)
        {
            if (model == null)
                return default;
            var entity = new Entity.PumpCurveMapping();
            entity.ID = model.MappingID;
            entity.CorpID = model.CorpID;
            entity.PumpID = model.PumpID;
            entity.CurveID = model.ID;
            entity.SortCode = model.SortCode;
            entity.IsWorking = model.IsWorking;
            return entity;
        }
 
        //组合
        private List<Model.PumpCurveExMapping> Combine(IEnumerable<Model.PumpCurveMapping> mapping_list, IEnumerable<Model.PumpCurve> curve_list)
        {
            if (mapping_list == null || mapping_list.Count() < 1)
                return default;
            if (curve_list == null || curve_list.Count() < 1)
                return default;
            var vm_list = new List<Model.PumpCurveExMapping>();
            foreach (var mapping in mapping_list)
            {
                var curve = curve_list.FirstOrDefault(x => x.ID == mapping.CurveID);
                if (curve != null)
                {
                    var vm = new Model.PumpCurveExMapping(curve, mapping);
                    vm_list.Add(vm);
                }
            }
            return vm_list;
        }
 
        //组合
        private List<Model.PumpCurveExMapping> Combine(Model.PumpCurve curve,IEnumerable<Model.PumpCurveMapping> mapping_list)
        {
            if (mapping_list == null || mapping_list.Count() < 1)
                return default;
            if (curve == null)
                return default;
            var vm_list = new List<Model.PumpCurveExMapping>();
            foreach (var mapping in mapping_list)
            {
                if (mapping.CurveID == curve.ID)
                {
                    var vm = new Model.PumpCurveExMapping(curve, mapping);
                    vm_list.Add(vm);
                }
            }
            return vm_list;
        }
 
 
 
    }
}