ningshuxia
2022-11-22 e0738c0754dd80a3b8d972f03d84b0611fd8254c
Merge branch 'master' of http://47.103.154.90:83/r/IStation/Service.V4.1
已修改2个文件
已添加9个文件
954 ■■■■■ 文件已修改
Application/IStation.Application.Product/config/Mapper.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.Product/iot_payment_record/IotPaymentRecord_Controller.cs 204 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.Product/iot_payment_record/dto/AddIotPaymentRecordInput.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.Product/iot_payment_record/dto/IotPaymentRecordDto.cs 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.Product/iot_payment_record/dto/UpdateIotPaymentRecordInput.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/IStation.DAL.Product/iot/IotPaymentRecord.cs 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/IStation.Model.Product/iot/IotPaymentRecord.cs 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service.Product/iot/iot_payment_record/IotPaymentRecord.cs 254 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service.Product/iot/iot_payment_record/IotPaymentRecord_Instance.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service.Product/iot/iot_payment_record/cache/IotPaymentRecordCacheHelper.cs 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Transfer/IStation.Transfer.Expert_SDC800/TransferHelper.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.Product/config/Mapper.cs
@@ -258,6 +258,16 @@
            #endregion
            #region ç‰©è”卡缴费记录
            config.ForType<AddIotPaymentRecordInput, Model.IotPaymentRecord>();
            config.ForType<UpdateIotPaymentRecordInput, Model.IotPaymentRecord>();
            config.ForType<Model.IotPaymentRecord, IotPaymentRecordDto>();
            #endregion
        }
    }
}
Application/IStation.Application.Product/iot_payment_record/IotPaymentRecord_Controller.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,204 @@
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>
    /// IotPaymentRecord
    /// </summary>
    [Route("Product/IotPaymentRecord")]
    [ApiDescriptionSettings("Product", Name = "物联卡缴费记录", Order = 1000)]
    public class IotPaymentRecord_Controller : IDynamicApiController
    {
        private readonly Service.IotPaymentRecord _service = new Service.IotPaymentRecord();
        #region Query
        /// <summary>
        /// é€šè¿‡ CorpID èŽ·å–
        /// </summary>
        [Route("GetByCorpID@V1.0")]
        [HttpGet]
        public List<IotPaymentRecordDto> GetByCorpID([FromQuery][Required] CorpIDInput input)
        {
            var list = _service.GetByCorpID(input.CorpID);
            var vm_list = list?.Select(x => x.Adapt<Model.IotPaymentRecord, IotPaymentRecordDto>()).ToList();
            return vm_list;
        }
        /// <summary>
        /// é€šè¿‡ ID èŽ·å–
        /// </summary>
        [Route("GetByID@V1.0")]
        [HttpGet]
        public IotPaymentRecordDto GetByID([FromQuery][Required] IDUnderCorpInput input)
        {
            var model = _service.GetByID(input.CorpID, input.ID);
            return model?.Adapt<Model.IotPaymentRecord, IotPaymentRecordDto>();
        }
        /// <summary>
        /// é€šè¿‡ Ids èŽ·å–
        /// </summary>
        [Route("GetByIds@V1.0")]
        [HttpGet]
        public List<IotPaymentRecordDto> GetByIds([FromQuery][Required] IdsUnderCorpInput input)
        {
            var ids = LongListHelper.ToList(input.Ids);
            var list = _service.GetByIds(input.CorpID, ids);
            var vm_list = list?.Select(x => x.Adapt<Model.IotPaymentRecord, IotPaymentRecordDto>()).ToList();
            return vm_list;
        }
        /// <summary>
        /// é€šè¿‡ ProductID èŽ·å–
        /// </summary>
        [Route("GetByProductID@V1.0")]
        [HttpGet]
        public List<IotPaymentRecordDto> GetByProductID([FromQuery] ProductIDUnderCorpInput input)
        {
            var list = _service.GetByProductID(input.CorpID, input.ProductID);
            var vmList = list?.Select(x => new IotPaymentRecordDto(x)).ToList();
            return vmList;
        }
        /// <summary>
        /// é€šè¿‡ ProductIds èŽ·å–
        /// </summary>
        [Route("GetByProductIds@V1.0")]
        [HttpGet]
        public List<IotPaymentRecordDto> GetByProductIds([FromQuery] ProductIdsUnderCorpInput input)
        {
            var productIds = LongListHelper.ToList(input.ProductIds);
            var list = _service.GetByProductIds(input.CorpID, productIds);
            var vmList = list?.Select(x => new IotPaymentRecordDto(x)).ToList();
            return vmList;
        }
        /// <summary>
        /// é€šè¿‡ BelongType and BelongID获取
        /// </summary>
        [Route("GetByBelongTypeAndBelongID@V1.0")]
        [HttpGet]
        public List<IotPaymentRecordDto> GetByBelongTypeAndBelongID([FromQuery][Required] BelongUnderCorpInput input)
        {
            var list = _service.GetByBelongTypeAndBelongID(input.CorpID, input.BelongType, input.BelongID);
            var vmList = list?.Select(x => new IotPaymentRecordDto(x)).ToList();
            return vmList;
        }
        #endregion
        #region Insert
        /// <summary>
        /// æ’入一条
        /// </summary>
        [Route("Insert@V1.0")]
        [HttpPost]
        public long Insert(AddIotPaymentRecordInput input)
        {
            if (input == null)
                return default;
            var model = input.Adapt<AddIotPaymentRecordInput, Model.IotPaymentRecord>();
            var id = _service.Insert(model);
            return id;
        }
        /// <summary>
        /// æ’入多条
        /// </summary>
        [Route("Inserts@V1.0")]
        [HttpPost]
        public bool Inserts(List<AddIotPaymentRecordInput> inputList)
        {
            if (inputList == null || inputList.Count < 1)
                return false;
            var list = inputList.Select(x => x.Adapt<AddIotPaymentRecordInput, Model.IotPaymentRecord>()).ToList();
            var bol = _service.Inserts(list);
            return bol;
        }
        #endregion
        #region Update
        /// <summary>
        /// æ›´æ–°ä¸€æ¡
        /// </summary>
        [Route("Update@V1.0")]
        [HttpPut]
        public bool Update(UpdateIotPaymentRecordInput input)
        {
            if (input == null)
                return false;
            var model = _service.GetByID(input.CorpID, input.ID);
            if (model == null)
                return false;
            var rhs = new Model.IotPaymentRecord(model);
            input.Adapt(rhs);
            var bol = _service.Update(rhs);
            return bol;
        }
        /// <summary>
        /// æ›´æ–°å¤šæ¡
        /// </summary>
        [Route("Updates@V1.0")]
        [HttpPut]
        public bool Updates(List<UpdateIotPaymentRecordInput> inputList)
        {
            if (inputList == null || inputList.Count() < 1)
            {
                return false;
            }
            var corpIds = inputList.Select(x => x.CorpID).Distinct().ToList();
            if (corpIds.Count > 1)
                return false;
            var modelList = _service.GetByIds(corpIds[0], inputList.Select(x => x.ID).ToList());
            if (modelList == null || modelList.Count < 1)
                return false;
            var rhsList = new List<Model.IotPaymentRecord>();
            modelList.ForEach(x => {
                var input = inputList.Find(t => t.ID == x.ID);
                if (input != null)
                {
                    var rhs = new Model.IotPaymentRecord(x);
                    input.Adapt(rhs);
                    rhsList.Add(rhs);
                }
            });
            if (rhsList.Count < 1)
                return false;
            var bol = _service.Updates(rhsList);
            return bol;
        }
        #endregion
        #region Delete
        /// <summary>
        /// åˆ é™¤
        /// </summary>
        [Route("DeleteByID@V1.0")]
        [HttpDelete]
        public DeleteReasonOutput DeleteByID([FromQuery][Required] IDUnderCorpInput input)
        {
            var bol = _service.DeleteByID(input.CorpID, input.ID, out string Msg);
            return new DeleteReasonOutput() { Success = bol, Reason = Msg };
        }
        #endregion
    }
}
Application/IStation.Application.Product/iot_payment_record/dto/AddIotPaymentRecordInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// æ·»åŠ ç‰©è”å¡ç¼´è´¹è®°å½•
    /// </summary>
    public class AddIotPaymentRecordInput
    {
        /// <summary>
        /// å®¢æˆ·æ ‡è¯†
        /// </summary>
        public long CorpID { get; set; }
        /// <summary>
        /// è®¾å¤‡æ ‡è¯†
        /// </summary>
        public long ProductID { get; set; }
        /// <summary>
        /// ç¼´è´¹äºº
        /// </summary>
        public string PayerName { get; set; }
        /// <summary>
        /// ç¼´è´¹æ—¶é—´
        /// </summary>
        public DateTime PaymentTime { get; set; }
        /// <summary>
        /// æœ‰æ•ˆå¤©æ•°
        /// </summary>
        public int ValidDays { get; set; }
        /// <summary>
        /// æœ‰æ•ˆé¢åº¦
        /// </summary>
        public double LimitValue { get; set; }
        /// <summary>
        /// è¯´æ˜Ž
        /// </summary>
        public string Description { get; set; }
    }
}
Application/IStation.Application.Product/iot_payment_record/dto/IotPaymentRecordDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,75 @@
using IStation.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    ///
    /// </summary>
    public class IotPaymentRecordDto
    {
        /// <summary>
        ///
        /// </summary>
        public IotPaymentRecordDto() { }
        /// <summary>
        ///
        /// </summary>
        public IotPaymentRecordDto(Model.IotPaymentRecord rhs)
        {
            this.ID = rhs.ID;
            this.CorpID = rhs.CorpID;
            this.ProductID = rhs.ProductID;
            this.PayerName = rhs.PayerName;
            this.PaymentTime = rhs.PaymentTime;
            this.ValidDays = rhs.ValidDays;
            this.LimitValue = rhs.LimitValue;
            this.Description = rhs.Description;
        }
        /// <summary>
        /// æ ‡è¯†
        /// </summary>
        public long ID { get; set; }
        /// <summary>
        /// å®¢æˆ·æ ‡è¯†
        /// </summary>
        public long CorpID { get; set; }
        /// <summary>
        /// è®¾å¤‡æ ‡è¯†
        /// </summary>
        public long ProductID { get; set; }
        /// <summary>
        /// ç¼´è´¹äºº
        /// </summary>
        public string PayerName { get; set; }
        /// <summary>
        /// ç¼´è´¹æ—¶é—´
        /// </summary>
        public DateTime PaymentTime { get; set; }
        /// <summary>
        /// æœ‰æ•ˆå¤©æ•°
        /// </summary>
        public int ValidDays { get; set; }
        /// <summary>
        /// æœ‰æ•ˆé¢åº¦
        /// </summary>
        public double LimitValue { get; set; }
        /// <summary>
        /// è¯´æ˜Ž
        /// </summary>
        public string Description { get; set; }
    }
}
Application/IStation.Application.Product/iot_payment_record/dto/UpdateIotPaymentRecordInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    ///
    /// </summary>
    public class UpdateIotPaymentRecordInput
    {
        /// <summary>
        /// æ ‡è¯†
        /// </summary>
        public long ID { get; set; }
        /// <summary>
        /// å®¢æˆ·æ ‡è¯†
        /// </summary>
        public long CorpID { get; set; }
        /// <summary>
        /// è®¾å¤‡æ ‡è¯†
        /// </summary>
        public long ProductID { get; set; }
        /// <summary>
        /// ç¼´è´¹äºº
        /// </summary>
        public string PayerName { get; set; }
        /// <summary>
        /// ç¼´è´¹æ—¶é—´
        /// </summary>
        public DateTime PaymentTime { get; set; }
        /// <summary>
        /// æœ‰æ•ˆå¤©æ•°
        /// </summary>
        public int ValidDays { get; set; }
        /// <summary>
        /// æœ‰æ•ˆé¢åº¦
        /// </summary>
        public double LimitValue { get; set; }
        /// <summary>
        /// è¯´æ˜Ž
        /// </summary>
        public string Description { get; set; }
    }
}
DAL/IStation.DAL.Product/iot/IotPaymentRecord.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
namespace IStation.DAL
{
    /// <summary>
    /// ç‰©è”卡缴费记录
    /// </summary>
    public partial class IotPaymentRecord : CorpDAL<Entity.IotPaymentRecord>
    {
        /// <summary>
        ///
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.DefaultConnectionConfig; }
        }
        /// <summary>
        /// é€šè¿‡ ProductID èŽ·å–
        /// </summary>
        public List<Entity.IotPaymentRecord> GetByProductID(long CorpID, long ProductID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.IotPaymentRecord>().Where(x => x.CorpID == CorpID && x.ProductID == ProductID).ToList();
            }
        }
        /// <summary>
        /// é€šè¿‡ ProductIds èŽ·å–
        /// </summary>
        public List<Entity.IotPaymentRecord> GetByProductIds(long CorpID, List<long> ProductIds)
        {
            if (ProductIds == null || ProductIds.Count < 1)
                return default;
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.IotPaymentRecord>().Where(x => x.CorpID == CorpID && ProductIds.Contains(x.ProductID)).ToList();
            }
        }
        /// <summary>
        /// é€šè¿‡ BelongType å’Œ BelongID èŽ·å–
        /// </summary>
        public List<Entity.IotPaymentRecord> GetByBelongTypeAndBelongID(long CorpID, string BelongType, long BelongID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.IotPaymentRecord, Entity.Product>((x, y) => x.ProductID == y.ID)
                    .Where((x, y) => y.CorpID == CorpID && y.BelongType == BelongType && y.BelongID == BelongID)
                    .Select(x => x).ToList();
            }
        }
    }
}
Model/IStation.Model.Product/iot/IotPaymentRecord.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,104 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
namespace IStation.Model
{
    /// <summary>
    /// ç‰©è”卡缴费记录
    /// </summary>
    public partial class IotPaymentRecord : System.ICloneable
    {
        /// <summary>
        ///
        /// </summary>
        public IotPaymentRecord() { }
        /// <summary>
        ///
        /// </summary>
        public IotPaymentRecord(IotPaymentRecord rhs)
        {
            this.ID = rhs.ID;
            this.CorpID = rhs.CorpID;
            this.ProductID = rhs.ProductID;
            this.PayerName = rhs.PayerName;
            this.PaymentTime = rhs.PaymentTime;
            this.ValidDays = rhs.ValidDays;
            this.LimitValue = rhs.LimitValue;
            this.Description = rhs.Description;
        }
        /// <summary>
        ///
        /// </summary>
        public void Reset(IotPaymentRecord rhs)
        {
            this.ID = rhs.ID;
            this.CorpID = rhs.CorpID;
            this.ProductID = rhs.ProductID;
            this.PayerName = rhs.PayerName;
            this.PaymentTime = rhs.PaymentTime;
            this.ValidDays = rhs.ValidDays;
            this.LimitValue = rhs.LimitValue;
            this.Description = rhs.Description;
        }
        /// <summary>
        /// æ ‡è¯†
        /// </summary>
        public long ID { get; set; }
        /// <summary>
        /// å®¢æˆ·æ ‡è¯†
        /// </summary>
        public long CorpID { get; set; }
        /// <summary>
        /// è®¾å¤‡æ ‡è¯†
        /// </summary>
        public long ProductID { get; set; }
        /// <summary>
        /// ç¼´è´¹äºº
        /// </summary>
        public string PayerName { get; set; }
        /// <summary>
        /// ç¼´è´¹æ—¶é—´
        /// </summary>
        public DateTime PaymentTime { get; set; }
        /// <summary>
        /// æœ‰æ•ˆå¤©æ•°
        /// </summary>
        public int ValidDays { get; set; }
        /// <summary>
        /// æœ‰æ•ˆé¢åº¦
        /// </summary>
        public double LimitValue { get; set; }
        /// <summary>
        /// è¯´æ˜Ž
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        ///
        /// </summary>
        public IotPaymentRecord Clone()
        {
            return (IotPaymentRecord)this.MemberwiseClone();
        }
        object ICloneable.Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
Service/IStation.Service.Product/iot/iot_payment_record/IotPaymentRecord.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,254 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Service
{
    /// <summary>
    /// ç‰©è”卡缴费记录
    /// </summary>
    public partial class IotPaymentRecord
    {
        #region Cache
        //通过 CorpID èŽ·å–ç¼“å­˜
        private List<Model.IotPaymentRecord> GetCorpCache(long CorpID)
        {
            return IotPaymentRecordCacheHelper.GetSet(CorpID, () =>
            {
                var dal = new DAL.IotPaymentRecord();
                var entity_list = dal.GetByCorpID(CorpID);
                var model_list = Entity2Models(entity_list);
                if (model_list == null)
                {
                    model_list = new List<Model.IotPaymentRecord>();
                }
                return model_list;
            }, ConfigHelper.CacheKeepTime, ConfigHelper.CacheRandomTime);
        }
        //通过 ID æ›´æ–°ç¼“å­˜
        internal void UpdateCorpCache(long CorpID, long ID)
        {
            var dal = new DAL.IotPaymentRecord();
            var entity_ds = dal.GetByID(CorpID, ID);
            var model_ds = Entity2Model(entity_ds);
            var all = GetCorpCache(CorpID);
            var model = all.Find(x => x.ID == ID);
            if (model == null)
            {
                all.Add(model_ds);
            }
            else
            {
                model.Reset(model_ds);
            }
        }
        //通过 Ids æ›´æ–°ç¼“å­˜
        private void UpdateCorpCache(long CorpID, List<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return;
            var dal = new DAL.IotPaymentRecord();
            var entity_list = dal.GetByIds(CorpID, Ids);
            var model_list = Entity2Models(entity_list);
            var all = GetCorpCache(CorpID);
            all.RemoveAll(x => Ids.Contains(x.ID));
            if (model_list != null && model_list.Count > 0)
            {
                all.AddRange(model_list);
            }
        }
        //移除缓存
        private void RemoveCorpCache(long CorpID, long ID)
        {
            var all = GetCorpCache(CorpID);
            all.RemoveAll(x => x.ID == ID);
        }
        #endregion
        #region Query
        /// <summary>
        /// é€šè¿‡ CorpID èŽ·å–
        /// </summary>
        public List<Model.IotPaymentRecord> GetByCorpID(long CorpID)
        {
            var all = GetCorpCache(CorpID);
            return all.OrderBy(x=>x.PaymentTime).ToList();
        }
        /// <summary>
        ///  é€šè¿‡ ID èŽ·å–
        /// </summary>
        public Model.IotPaymentRecord GetByID(long CorpID, long ID)
        {
            var all = GetByCorpID(CorpID);
            return all.Find(x => x.ID == ID);
        }
        /// <summary>
        /// é€šè¿‡ Ids获取
        /// </summary>
        public List<Model.IotPaymentRecord> GetByIds(long CorpID, List<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return default;
            var all = GetByCorpID(CorpID);
            return all.Where(x => Ids.Contains(x.ID)).OrderBy(x=>x.PaymentTime).ToList();
        }
        /// <summary>
        /// é€šè¿‡ ProductID èŽ·å–
        /// </summary>
        public List<Model.IotPaymentRecord> GetByProductID(long CorpID, long ProductID)
        {
            var all = GetByCorpID(CorpID);
            return all.Where(x => x.ProductID == ProductID).OrderBy(x => x.PaymentTime).ToList();
        }
        /// <summary>
        /// é€šè¿‡ ProductIds èŽ·å–
        /// </summary>
        public List<Model.IotPaymentRecord> GetByProductIds(long CorpID, List<long> ProductIds)
        {
            if (ProductIds == null || ProductIds.Count < 1)
                return default;
            var all=GetByCorpID(CorpID);
            return all.Where(x => ProductIds.Contains(x.ProductID)).OrderBy(x => x.PaymentTime).ToList();
        }
        /// <summary>
        /// é€šè¿‡ BelongType å’Œ BelongID èŽ·å–
        /// </summary>
        public List<Model.IotPaymentRecord> GetByBelongTypeAndBelongID(long CorpID, string BelongType, long BelongID)
        {
            var productList = new Product().GetByBelongTypeAndBelongID(CorpID,BelongType,BelongID);
            if (productList == null || productList.Count < 1)
                return default;
            var all = GetByCorpID(CorpID);
            var list = (from x in all join y in productList on x.ProductID equals y.ID orderby x.PaymentTime select x).ToList();
            return list;
        }
        #endregion
        #region Insert
        /// <summary>
        /// æ’入一条数据
        /// </summary>
        public long Insert(Model.IotPaymentRecord model)
        {
            if (model == null)
                return default;
            if (model.CorpID < 1)
                return default;
            var dal = new DAL.IotPaymentRecord();
            var entity = Model2Entity(model);
            var id = dal.Insert(entity);
            if (id > 0)
            {
                UpdateCorpCache(model.CorpID, id);
            }
            return id;
        }
        /// <summary>
        /// æ’入多条
        /// </summary>
        public bool Inserts(IEnumerable<Model.IotPaymentRecord> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var corpIds = list.Select(x => x.CorpID).Distinct().ToList();
            if (corpIds.Count != 1 || corpIds[0] < 1)
                return default;
            var dal = new DAL.IotPaymentRecord();
            var entity_list = Model2Entities(list.ToList());
            var ids = dal.InsertsR(entity_list);
            if (ids != null && ids.Count > 0)
            {
                UpdateCorpCache(corpIds[0], ids);
                return true; ;
            }
            return default;
        }
        #endregion
        #region Update
        /// <summary>
        /// æ›´æ–°ä¸€æ¡
        /// </summary>
        public bool Update(Model.IotPaymentRecord model)
        {
            if (model == null)
                return default;
            if (model.CorpID < 1)
                return default;
            if (model.ID < 1)
                return default;
            var dal = new DAL.IotPaymentRecord();
            var entity = Model2Entity(model);
            var bol = dal.Update(entity);
            if (bol)
            {
                UpdateCorpCache(model.CorpID, model.ID);
            }
            return bol;
        }
        /// <summary>
        /// æ‰¹é‡æ›´æ–°
        /// </summary>
        public bool Updates(List<Model.IotPaymentRecord> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var corpIds = list.Select(x => x.CorpID).Distinct().ToList();
            if (corpIds.Count != 1 || corpIds[0] < 1)
                return default;
            if (list.ToList().Exists(x => x.ID < 1))
                return default;
            var dal = new DAL.IotPaymentRecord();
            var entity_list = Model2Entities(list.ToList());
            var bol = dal.Updates(entity_list);
            if (bol)
            {
                UpdateCorpCache(corpIds[0], list.Select(x => x.ID).ToList());
            }
            return bol;
        }
        #endregion
        #region Delete
        /// <summary>
        /// é€šè¿‡ ID åˆ é™¤
        /// </summary>
        public bool DeleteByID(long CorpID, long ID, out string Msg)
        {
            Msg = string.Empty;
            var dal = new DAL.IotPaymentRecord();
            var bol = dal.DeleteByID(CorpID, ID);
            if (bol)
            {
                RemoveCorpCache(CorpID, ID);
            }
            return bol;
        }
        #endregion
    }
}
Service/IStation.Service.Product/iot/iot_payment_record/IotPaymentRecord_Instance.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,66 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Service
{
    /// <summary>
    ///
    /// </summary>
    public partial class IotPaymentRecord
    {
        //Entity to GetModel
        private Model.IotPaymentRecord Entity2Model(Entity.IotPaymentRecord entity)
        {
            if (entity == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.IotPaymentRecord, Model.IotPaymentRecord>()).CreateMapper();
            var model = mapper.Map<Entity.IotPaymentRecord, Model.IotPaymentRecord>(entity);
            return model;
        }
        //Entities to GetModels
        private List<Model.IotPaymentRecord> Entity2Models(List<Entity.IotPaymentRecord> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.IotPaymentRecord, Model.IotPaymentRecord>()).CreateMapper();
            var models = mapper.Map<List<Entity.IotPaymentRecord>, List<Model.IotPaymentRecord>>(entities);
            return models;
        }
        //Model to Entity
        private Entity.IotPaymentRecord Model2Entity(Model.IotPaymentRecord model)
        {
            if (model == null)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.IotPaymentRecord, Entity.IotPaymentRecord>()).CreateMapper();
            var entity = mapper.Map<Model.IotPaymentRecord, Entity.IotPaymentRecord>(model);
            return entity;
        }
        //Models to Entities
        private List<Entity.IotPaymentRecord> Model2Entities(List<Model.IotPaymentRecord> models)
        {
            if (models == null || models.Count < 1)
                return default;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.IotPaymentRecord, Entity.IotPaymentRecord>()).CreateMapper();
            var entities = mapper.Map<List<Model.IotPaymentRecord>, List<Entity.IotPaymentRecord>>(models);
            return entities;
        }
        //Model to Entity
        private void Model2Entity(Model.IotPaymentRecord model, Entity.IotPaymentRecord entity)
        {
            if (model == null || entity == null)
                return;
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.IotPaymentRecord, Entity.IotPaymentRecord>()).CreateMapper();
            mapper.Map(model, entity);
        }
    }
}
Service/IStation.Service.Product/iot/iot_payment_record/cache/IotPaymentRecordCacheHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Service
{
    /// <summary>
    /// IotPaymentRecord缓存辅助类
    /// </summary>
    internal class IotPaymentRecordCacheHelper
    {
        private const string _contentKey = "IotPaymentRecordListKey";
        private static string GetCacheKey(long CorpID)
        {
            var contentKey = string.Format("{0}-{1}", _contentKey, CorpID);
            return CacheHelper.GetCacheKey(contentKey);
        }
        /// <summary>
        /// è®¾ç½®ç¼“å­˜
        /// </summary>
        public static void Set(long CorpID, List<Model.IotPaymentRecord> list, int Minites = 30, int RandomSeconds = 0)
        {
            var cacheKey = GetCacheKey(CorpID);
            MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds);
        }
        /// <summary>
        /// èŽ·å–ç¼“å­˜
        /// </summary>
        public static List<Model.IotPaymentRecord> Get(long CorpID)
        {
            var cacheKey = GetCacheKey(CorpID);
            return MemoryCacheHelper.Get<List<Model.IotPaymentRecord>>(cacheKey);
        }
        /// <summary>
        /// èŽ·å–è®¾ç½®ç¼“å­˜
        /// </summary>
        public static List<Model.IotPaymentRecord> GetSet(long CorpID, Func<List<Model.IotPaymentRecord>> func, int Minites = 30, int RandomSeconds = 0)
        {
            var cacheKey = GetCacheKey(CorpID);
            return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds);
        }
        /// <summary>
        /// ç§»é™¤ç¼“å­˜
        /// </summary>
        public static void Remove(long CorpID)
        {
            var cacheKey = GetCacheKey(CorpID);
            MemoryCacheHelper.Remove(cacheKey);
        }
        /// <summary>
        /// å…¨éƒ¨ç§»é™¤
        /// </summary>
        public static void RemoveAll()
        {
            MemoryCacheHelper.Remove((key) =>
            {
                return key.Contains(CacheHelper.GetCacheKey(_contentKey));
            });
        }
    }
}
Transfer/IStation.Transfer.Expert_SDC800/TransferHelper.cs
@@ -34,7 +34,7 @@
                    {
                        var list = DataHelper.GetRecordList(model);
                        var result = BulkInsert(list);
                        LogHelper.Info($"{model.IP}:上传{result}!");
                        LogHelper.Info($"{model.IP}:上传{result},采样点数:{model.Len}!");
                    }
                }
            });