diff --git a/Ewide.Nbzs.BackWorkerService/DbManage.cs b/Ewide.Nbzs.BackWorkerService/DbManage.cs index f647fb4..31eae7a 100644 --- a/Ewide.Nbzs.BackWorkerService/DbManage.cs +++ b/Ewide.Nbzs.BackWorkerService/DbManage.cs @@ -46,5 +46,9 @@ namespace Ewide.Nbzs.BackWorkerService { return GetDbClient().GetConnection(id); } + public static string GetHashKey() + { + return App.GetConfig("AesHashKey"); + } } } diff --git a/Ewide.Nbzs.BackWorkerService/Ewide.Nbzs.BackWorkerService.csproj b/Ewide.Nbzs.BackWorkerService/Ewide.Nbzs.BackWorkerService.csproj index 331bf55..f373786 100644 --- a/Ewide.Nbzs.BackWorkerService/Ewide.Nbzs.BackWorkerService.csproj +++ b/Ewide.Nbzs.BackWorkerService/Ewide.Nbzs.BackWorkerService.csproj @@ -6,12 +6,14 @@ + + diff --git a/Ewide.Nbzs.BackWorkerService/Program.cs b/Ewide.Nbzs.BackWorkerService/Program.cs index 542c068..8d64197 100644 --- a/Ewide.Nbzs.BackWorkerService/Program.cs +++ b/Ewide.Nbzs.BackWorkerService/Program.cs @@ -24,6 +24,13 @@ namespace Ewide.Nbzs.BackWorkerService .ConfigureServices((hostContext, services) => { services.AddHostedService(); + services.AddStackExchangeRedisCache(options => + { + // 连接字符串,这里也可以读取配置文件 + options.Configuration = App.GetConfig("RedisConfig"); + // 键名前缀 + options.InstanceName = "zlb_"; + }); }).UseSerilogDefault(); } } diff --git a/Ewide.Nbzs.BackWorkerService/Worker.cs b/Ewide.Nbzs.BackWorkerService/Worker.cs index 9bfbbde..defafbb 100644 --- a/Ewide.Nbzs.BackWorkerService/Worker.cs +++ b/Ewide.Nbzs.BackWorkerService/Worker.cs @@ -1,6 +1,11 @@ +using Ewide.Core; using Ewide.Nbzs.Entity; +using Ewide.Nbzs.Entity.Extends; using Furion; +using Furion.DataEncryption; +using Furion.JsonSerialization; using Furion.TaskScheduler; +using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using SqlSugar; @@ -18,11 +23,20 @@ namespace Ewide.Nbzs.BackWorkerService private readonly ILogger _logger; readonly SqlSugarProvider db_Product_Conn; readonly SqlSugarProvider db_Zlb_Conn; + //private readonly IDistributedCache _cache; + private readonly ICache _cache; + //, IDistributedCache cache public Worker(ILogger logger) { _logger = logger; db_Product_Conn = DbManage.GetConnection("Product_Conn"); db_Zlb_Conn = DbManage.GetConnection("Zlb_Conn"); + //_cache = cache; + _cache = new RedisCache(Microsoft.Extensions.Options.Options.Create(new CacheOptions + { + CacheType = CacheType.RedisCache, + RedisConnectionString = App.GetConfig("RedisConfig") + })); } protected override async Task ExecuteAsync(CancellationToken stoppingToken) @@ -88,6 +102,7 @@ namespace Ewide.Nbzs.BackWorkerService private List Push(PushZlb pushZlbObj) { + //测试读取接口中缓存 _logger.LogInformation("进入Push方法():Id:{Id} ,项目ID:{PrjId} at: {time}", pushZlbObj.ID, pushZlbObj.PrjId, DateTimeOffset.Now); List list_result = new(); try @@ -96,80 +111,181 @@ namespace Ewide.Nbzs.BackWorkerService var project = db_Product_Conn.Queryable().Where(p => p.ID == projectId).First(); if (project != null) { + #region 政策 + _cache.Set($"CacheData-PoliciesRegulations", db_Zlb_Conn.Queryable().ToList()); + + var listPoliciesRegulations = db_Product_Conn.Queryable().ToList(); + //_cache.SetString($"CacheData-PoliciesRegulations", JSON.Serialize(listPoliciesRegulations), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); //删政策 - var delete_result = db_Zlb_Conn.Deleteable().ExecuteCommandHasChange(); + var delete_result = db_Zlb_Conn.Deleteable().ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "PoliciesRegulations", IsSuccess = delete_result }); + + var insert_result = db_Zlb_Conn.Insertable(listPoliciesRegulations).ExecuteCommand(); + list_result.Add(new PushResult { Action = "Insert", TableName = "PoliciesRegulations", IsSuccess = insert_result > 0 }); + _cache.Set($"CacheData-PoliciesRegulations", db_Zlb_Conn.Queryable().ToList()); + #endregion + + #region 非住宅协议 + _cache.Set($"CacheData-ResidentialAgreement", GetBcxyData()); //if (delete_result) //{ - var insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().ToList()).ExecuteCommand(); - list_result.Add(new PushResult { Action = "Insert", TableName = "PoliciesRegulations", IsSuccess = insert_result > 0 }); - //} + //加密敏感字段 + var listNonResidentialAgreement = db_Product_Conn.Queryable().Where(p => p.ProjectID == projectId).ToList(); + listNonResidentialAgreement.ForEach(p => + { + p.ExpropriatedCardNo = AESEncryption.Encrypt(p.ExpropriatedCardNo, DbManage.GetHashKey()); + p.ExpropriatedPhone = AESEncryption.Encrypt(p.ExpropriatedPhone, DbManage.GetHashKey()); + }); + //_cache.SetString($"CacheData-NonResidentialAgreement-{projectId}", JSON.Serialize(listNonResidentialAgreement), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); + //删除非住宅协议 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectID == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "NonResidentialAgreement", IsSuccess = delete_result }); - //if (delete_result) - //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectID == projectId).ToList()).ExecuteCommand(); + + insert_result = db_Zlb_Conn.Insertable(listNonResidentialAgreement).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "NonResidentialAgreement", IsSuccess = insert_result > 0 }); - //} + + + #endregion + + #region 住宅协议 + + //加密敏感字段 + var listResidentialAgreement = db_Product_Conn.Queryable().Where(p => p.ProjectID == projectId).ToList(); + listResidentialAgreement.ForEach(p => + { + p.ExpropriatedCardNo = AESEncryption.Encrypt(p.ExpropriatedCardNo, DbManage.GetHashKey()); + p.ExpropriatedPhone = AESEncryption.Encrypt(p.ExpropriatedPhone, DbManage.GetHashKey()); + }); + //_cache.SetString($"CacheData-ResidentialAgreement-{projectId}", JSON.Serialize(listResidentialAgreement), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); //删除住宅协议 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectID == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "ResidentialAgreement", IsSuccess = delete_result }); - //if (delete_result) - //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectID == projectId).ToList()).ExecuteCommand(); + + insert_result = db_Zlb_Conn.Insertable(listResidentialAgreement).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "ResidentialAgreement", IsSuccess = insert_result > 0 }); - //} + + _cache.Set($"CacheData-ResidentialAgreement", GetBcxyData()); + #endregion + + #region 非住宅评估 + _cache.Set($"CacheData-InvestigateTable_Assessment", GetFHPGData()); + var listNonInvestigateTable_Assessment = db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList(); + //_cache.SetString($"CacheData-NonInvestigateTable_Assessment-{projectId}", JSON.Serialize(listNonInvestigateTable_Assessment), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); //删除非住宅评估 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectId == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "NonInvestigateTable_Assessment", IsSuccess = delete_result }); - //if (delete_result) - //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList()).ExecuteCommand(); + + insert_result = db_Zlb_Conn.Insertable(listNonInvestigateTable_Assessment).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "NonInvestigateTable_Assessment", IsSuccess = insert_result > 0 }); - //} + + #endregion + + #region 住宅评估 + var listInvestigateTable_Assessment = db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList(); + //_cache.SetString($"CacheData-InvestigateTable_Assessment-{projectId}", JSON.Serialize(listInvestigateTable_Assessment), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); //删除住宅评估 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectId == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "InvestigateTable_Assessment", IsSuccess = delete_result }); - //if (delete_result) - //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList()).ExecuteCommand(); + + insert_result = db_Zlb_Conn.Insertable(listInvestigateTable_Assessment).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "InvestigateTable_Assessment", IsSuccess = insert_result > 0 }); - //} + + _cache.Set($"CacheData-InvestigateTable_Assessment", GetFHPGData()); + #endregion + + #region 非住宅调查表 + _cache.Set($"CacheData-NonResidentialInvestigateTable", db_Zlb_Conn.Queryable().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, ExpropriatedCardNo = p.PropertyRightPrsonCardNo }).ToList()); //删除非住宅调查表 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectId == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "NonResidentialInvestigateTable", IsSuccess = delete_result }); - //if (delete_result) + + //加密敏感字段 + var listNonInvestigateTable = db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList(); + listNonInvestigateTable.ForEach(p => + { + p.PropertyRightPrsonCardNo = AESEncryption.Encrypt(p.PropertyRightPrsonCardNo, DbManage.GetHashKey()); + p.TheLegalRepresentativePhone = AESEncryption.Encrypt(p.TheLegalRepresentativePhone, DbManage.GetHashKey()); + }); + //_cache.SetString($"CacheData-NonResidentialInvestigateTable-{projectId}", JSON.Serialize(listNonInvestigateTable), new DistributedCacheEntryOptions //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList()).ExecuteCommand(); + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); + insert_result = db_Zlb_Conn.Insertable(listNonInvestigateTable).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "NonResidentialInvestigateTable", IsSuccess = insert_result > 0 }); - //} + _cache.Set($"CacheData-NonResidentialInvestigateTable", db_Zlb_Conn.Queryable().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, ExpropriatedCardNo = p.PropertyRightPrsonCardNo }).ToList()); + #endregion + + #region 住宅调查表 + _cache.Set($"CacheData-InvestigateTable", db_Zlb_Conn.Queryable().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, p.ExpropriatedCardNo }).ToList()); //删除住宅调查表 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectId == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "InvestigateTable", IsSuccess = delete_result }); - //if (delete_result) + + //加密敏感字段 + var listInvestigateTable = db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList(); + listInvestigateTable.ForEach(p => + { + p.ExpropriatedCardNo = AESEncryption.Encrypt(p.ExpropriatedCardNo, DbManage.GetHashKey()); + p.ExpropriatedPhone = AESEncryption.Encrypt(p.ExpropriatedPhone, DbManage.GetHashKey()); + }); + //_cache.SetString($"CacheData-InvestigateTable-{projectId}", JSON.Serialize(listInvestigateTable), new DistributedCacheEntryOptions //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectId == projectId).ToList()).ExecuteCommand(); + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); + insert_result = db_Zlb_Conn.Insertable(listInvestigateTable).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "InvestigateTable", IsSuccess = insert_result > 0 }); - //} + _cache.Set($"CacheData-InvestigateTable", db_Zlb_Conn.Queryable().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, p.ExpropriatedCardNo }).ToList()); + #endregion + + #region 项目 + _cache.Set($"CacheData-Projects", GetProjectData()); + var listProjects = db_Product_Conn.Queryable().Where(p => p.ID == projectId).ToList(); + //_cache.SetString($"CacheData-Projects-{projectId}", JSON.Serialize(listProjects), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); //删项目 delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ID == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "Projects", IsSuccess = delete_result }); - //if (delete_result) - //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ID == projectId).ToList()).ExecuteCommand(); - list_result.Add(new PushResult { Action = "Insert", TableName = "Projects", IsSuccess = insert_result > 0 }); - //} + insert_result = db_Zlb_Conn.Insertable(listProjects).ExecuteCommand(); + list_result.Add(new PushResult { Action = "Insert", TableName = "Projects", IsSuccess = insert_result > 0 }); + _cache.Set($"CacheData-Projects", GetProjectData()); + #endregion + + #region ProjectsStep + _cache.Set($"CacheData-ProjectsStep", db_Zlb_Conn.Queryable().ToList()); + var listProjectsStep = db_Product_Conn.Queryable().Where(p => p.ProjectID == projectId).ToList(); + //_cache.SetString($"CacheData-ProjectsStep-{projectId}", JSON.Serialize(listProjectsStep), new DistributedCacheEntryOptions + //{ + // SlidingExpiration = TimeSpan.FromMinutes(60) + //}); //ProjectsStep delete_result = db_Zlb_Conn.Deleteable().Where(p => p.ProjectID == projectId).ExecuteCommandHasChange(); list_result.Add(new PushResult { Action = "Delete", TableName = "ProjectsStep", IsSuccess = delete_result }); - //if (delete_result) - //{ - insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable().Where(p => p.ProjectID == projectId).ToList()).ExecuteCommand(); + + insert_result = db_Zlb_Conn.Insertable(listProjectsStep).ExecuteCommand(); list_result.Add(new PushResult { Action = "Insert", TableName = "ProjectsStep", IsSuccess = insert_result > 0 }); - //} - + + _cache.Set($"CacheData-ProjectsStep", db_Zlb_Conn.Queryable().ToList()); + #endregion + } StringBuilder push_error_reason = new(); //if (list_result.Any(r => !r.IsSuccess)) @@ -204,6 +320,18 @@ namespace Ewide.Nbzs.BackWorkerService _logger.LogInformation("离开Push方法():Id:{Id} ,项目ID:{PrjId} at: {time}", pushZlbObj.ID, pushZlbObj.PrjId, DateTimeOffset.Now); return list_result; } + private List GetProjectData() + { + return db_Zlb_Conn.Ado.SqlQuery("select status,a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'号') zsjdh,dbo.get_current_state(a.ID) CurrentState,NAME,CreateRecordTime from Projects a "); + } + private List GetFHPGData() + { + return db_Zlb_Conn.Ado.SqlQuery("select d.id,e.ProjectId as PrjId ,d.AssessmentNo,e.HouseAddress,d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,1 type from InvestigateTable_Assessment d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.IsPublic=1 union all select d.id,e.ProjectId as PrjId ,AssessmentNo, e.HouseAddress, d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,2 type from NonInvestigateTable_Assessment d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.IsPublic=1 ;"); + } + private List GetBcxyData() + { + return db_Zlb_Conn.Ado.SqlQuery("select d.id,isnull(d.CollectDecisionNoHeadName,'')+isnull(d.No1,'')+'-'+isnull(d.No2,'')+(case when (d.No3 is null or d.No3 = '') then '' else ('-'+d.No3) end ) XyNo,d.SwitchProductionWay,e.HouseAddress,d.SummationShouldCompensateMoney,e.ProjectId as PrjId,e.id dcbId,d.SignTime,1 type from ResidentialAgreement d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.IsInRecords = 1 union all select d.id,isnull(d.CollectDecisionNoHeadName, '') + isnull(d.No2, '') + '-' + isnull(d.No3, '') XyNo , d.SwitchProductionWay, e.HouseAddress, d.SummationShouldCompensateMoney, e.ProjectId as PrjId,e.id dcbId,d.SignTime,2 type from NonResidentialAgreement d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.IsInRecords = 1 ; "); + } } public class PushResult { diff --git a/Ewide.Nbzs.BackWorkerService/appsettings.json b/Ewide.Nbzs.BackWorkerService/appsettings.json index 27f8c8d..29c502d 100644 --- a/Ewide.Nbzs.BackWorkerService/appsettings.json +++ b/Ewide.Nbzs.BackWorkerService/appsettings.json @@ -34,5 +34,7 @@ "Enabled": true, "ConnectionString": "data source=118.178.224.202;initial catalog=NbzsZlb;persist security info=True;user id=KYSQLSERVERADMIN;password=KYDBLogin20161103...;MultipleActiveResultSets=True;App=EntityFramework" } - ] + ], + "AesHashKey": "A4D58EAF1948B29E5954B3DB425D5F2C", + "RedisConfig": "10.19.94.250:6380,password=nbzszlb!@#" } diff --git a/Ewide.Nbzs.Entity/Extends/H5IndexPrjModel.cs b/Ewide.Nbzs.Entity/Extends/H5IndexPrjModel.cs index 16fc1b0..047211b 100644 --- a/Ewide.Nbzs.Entity/Extends/H5IndexPrjModel.cs +++ b/Ewide.Nbzs.Entity/Extends/H5IndexPrjModel.cs @@ -16,6 +16,7 @@ namespace Ewide.Nbzs.Entity.Extends { public string dcbId { get; set; } public string PrjId { get; set; } + public string ExpropriatedCardNo { get; set; } } public class Fhpgs { @@ -95,6 +96,7 @@ namespace Ewide.Nbzs.Entity.Extends /// 琛ュ伩鍗忚闆嗗悎 /// public List BcxyList { get; set; } + public int status { get; set; } } public class PoliciesRegulations { diff --git a/Ewide.NbzsZheliban/Service/DataService.cs b/Ewide.NbzsZheliban/Service/DataService.cs index c6c8299..b02869d 100644 --- a/Ewide.NbzsZheliban/Service/DataService.cs +++ b/Ewide.NbzsZheliban/Service/DataService.cs @@ -19,6 +19,7 @@ using System.Text; using System.Threading.Tasks; using Furion.RemoteRequest.Extensions; using Microsoft.AspNetCore.Hosting; +using Ewide.Core; namespace Ewide.NbzsZheliban.Service { @@ -28,12 +29,18 @@ namespace Ewide.NbzsZheliban.Service private readonly ISqlSugarRepository repository; private readonly SqlSugarClient db; private readonly IJsonSerializerProvider _jsonSerializer; + private readonly ICache _cache; public DataService(ISqlSugarRepository sqlSugarRepository, IJsonSerializerProvider jsonSerializer, IHostingEnvironment hostingEnvironment) { repository = sqlSugarRepository; db = repository.Context; _jsonSerializer = jsonSerializer; this._hostingEnvironment = hostingEnvironment; + _cache = new RedisCache(Microsoft.Extensions.Options.Options.Create(new CacheOptions + { + CacheType = CacheType.RedisCache, + RedisConnectionString = App.GetConfig("RedisConfig") + })); } /// @@ -92,8 +99,12 @@ namespace Ewide.NbzsZheliban.Service /// private async Task> GetzzDcbsAsync(string cardno) { - //浣忓畢璋冩煡琛 - return await db.Ado.SqlQueryAsync("select ID dcbId,ProjectId PrjId from InvestigateTable b where b.ExpropriatedCardNo=@ExpropriatedCardNo", new List { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray()); + var list = _cache.Get>("CacheData-InvestigateTable"); + if (list != null && list.Count > 0) + return list.Where(p => p.ExpropriatedCardNo == cardno).ToList(); + else + //浣忓畢璋冩煡琛 + return await db.Ado.SqlQueryAsync("select ID dcbId,ProjectId PrjId from InvestigateTable b where b.ExpropriatedCardNo=@ExpropriatedCardNo", new List { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray()); } /// /// 闈炰綇瀹呰皟鏌ヨ〃 @@ -102,8 +113,12 @@ namespace Ewide.NbzsZheliban.Service /// private async Task> GetfzzDcbsAsync(string cardno) { - //闈炰綇瀹呰皟鏌ヨ〃 - return await db.Ado.SqlQueryAsync("select ID dcbId,ProjectId PrjId from NonResidentialInvestigateTable b where b.PropertyRightPrsonCardNo=@ExpropriatedCardNo", new List { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray()); + var list = _cache.Get>("CacheData-NonResidentialInvestigateTable"); + if (list != null && list.Count > 0) + return list.Where(p => p.ExpropriatedCardNo == cardno).ToList(); + else + //闈炰綇瀹呰皟鏌ヨ〃 + return await db.Ado.SqlQueryAsync("select ID dcbId,ProjectId PrjId from NonResidentialInvestigateTable b where b.PropertyRightPrsonCardNo=@ExpropriatedCardNo", new List { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray()); } /// /// 椤圭洰鍒楄〃 @@ -112,39 +127,62 @@ namespace Ewide.NbzsZheliban.Service /// private async Task> GetPrjListAsync(IEnumerable list_dcbs) { - //椤圭洰鍒楄〃 - return await db.Ado.SqlQueryAsync("select a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'鍙') zsjdh,dbo.get_current_state(a.ID) CurrentState,NAME,CreateRecordTime from Projects a where status = 2 and ID in ('" + string.Join("','", list_dcbs.Select(p => p.PrjId)) + "') "); + var list = _cache.Get>("CacheData-Projects"); + if (list != null && list.Count > 0) + return list.Where(p => p.status == 2 && list_dcbs.Select(p => p.PrjId).Contains(p.PrjId)).ToList(); + else + //椤圭洰鍒楄〃 + return await db.Ado.SqlQueryAsync("select a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'鍙') zsjdh,dbo.get_current_state(a.ID) CurrentState,NAME,CreateRecordTime from Projects a where status = 2 and ID in ('" + string.Join("','", list_dcbs.Select(p => p.PrjId)) + "') "); } /// /// 鍒嗘埛璇勪及 /// /// /// - private async Task> GetFHPGListAsync(string InvestigateTableID_param) + private async Task> GetFHPGListAsync(IEnumerable list_dcbs) { - //鍒嗘埛璇勪及 - return await db.Ado.SqlQueryAsync("select d.id,e.ProjectId as PrjId ,d.AssessmentNo,e.HouseAddress,d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,1 type from InvestigateTable_Assessment d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.IsPublic=1 and d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,e.ProjectId as PrjId ,AssessmentNo, e.HouseAddress, d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,2 type from NonInvestigateTable_Assessment d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.IsPublic=1 and d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ) ;"); + var list = _cache.Get>("CacheData-InvestigateTable_Assessment"); + if (list != null && list.Count > 0) + return list.Where(p => list_dcbs.Select(p => p.dcbId).Contains(p.dcbId)).ToList(); + else + { + var InvestigateTableID_param = "'" + string.Join("','", list_dcbs.Select(p => p.dcbId)) + "'"; + //鍒嗘埛璇勪及 + return await db.Ado.SqlQueryAsync("select d.id,e.ProjectId as PrjId ,d.AssessmentNo,e.HouseAddress,d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,1 type from InvestigateTable_Assessment d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.IsPublic=1 and d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,e.ProjectId as PrjId ,AssessmentNo, e.HouseAddress, d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,2 type from NonInvestigateTable_Assessment d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.IsPublic=1 and d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ) ;"); + } } /// /// 琛ュ伩鍗忚 /// /// /// - private async Task> GetBCXYListAsync(string InvestigateTableID_param) + private async Task> GetBCXYListAsync(IEnumerable list_dcbs) { - //琛ュ伩鍗忚 - return await db.Ado.SqlQueryAsync("select d.id,isnull(d.CollectDecisionNoHeadName,'')+isnull(d.No1,'')+'-'+isnull(d.No2,'')+(case when (d.No3 is null or d.No3 = '') then '' else ('-'+d.No3) end ) XyNo,d.SwitchProductionWay,e.HouseAddress,d.SummationShouldCompensateMoney,e.ProjectId as PrjId,e.id dcbId,d.SignTime,1 type from ResidentialAgreement d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.IsInRecords = 1 and d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,isnull(d.CollectDecisionNoHeadName, '') + isnull(d.No2, '') + '-' + isnull(d.No3, '') XyNo , d.SwitchProductionWay, e.HouseAddress, d.SummationShouldCompensateMoney, e.ProjectId as PrjId,e.id dcbId,d.SignTime,2 type from NonResidentialAgreement d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.IsInRecords = 1 and d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ); "); + var list = _cache.Get>("CacheData-InvestigateTable_Assessment"); + if (list != null && list.Count > 0) + return list.Where(p => list_dcbs.Select(p => p.dcbId).Contains(p.dcbId)).ToList(); + else + { + var InvestigateTableID_param = "'" + string.Join("','", list_dcbs.Select(p => p.dcbId)) + "'"; + //琛ュ伩鍗忚 + return await db.Ado.SqlQueryAsync("select d.id,isnull(d.CollectDecisionNoHeadName,'')+isnull(d.No1,'')+'-'+isnull(d.No2,'')+(case when (d.No3 is null or d.No3 = '') then '' else ('-'+d.No3) end ) XyNo,d.SwitchProductionWay,e.HouseAddress,d.SummationShouldCompensateMoney,e.ProjectId as PrjId,e.id dcbId,d.SignTime,1 type from ResidentialAgreement d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.IsInRecords = 1 and d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,isnull(d.CollectDecisionNoHeadName, '') + isnull(d.No2, '') + '-' + isnull(d.No3, '') XyNo , d.SwitchProductionWay, e.HouseAddress, d.SummationShouldCompensateMoney, e.ProjectId as PrjId,e.id dcbId,d.SignTime,2 type from NonResidentialAgreement d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.IsInRecords = 1 and d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ); "); + } } private async Task GetInfoByCardNoAsync(string cardno, string username) { + //var cardno_aes = AESEncryption.Decrypt(cardno, Common.GetHashKey()); var list_zz_dcb = await GetzzDcbsAsync(cardno); var list_fzz_dcb = await GetfzzDcbsAsync(cardno); //璋冩煡琛ㄩ泦鍚 var list_dcbs = list_zz_dcb.Concat(list_fzz_dcb); var list_projects = await GetPrjListAsync(list_dcbs); - var InvestigateTableID_param = "'" + string.Join("','", list_dcbs.Select(p => p.dcbId)) + "'"; - var list_fhpgs = await GetFHPGListAsync(InvestigateTableID_param); - var list_bcxys = await GetBCXYListAsync(InvestigateTableID_param); + + var list_fhpgs = await GetFHPGListAsync(list_dcbs); + var list_bcxys = await GetBCXYListAsync(list_dcbs); + ////瑙e瘑 + //list_bcxys.ForEach(xy=> { + //xy.ExpropriatedCardNo= AESEncryption.Decrypt(xy.ExpropriatedCardNo, Common.GetHashKey()); + //}); var listAreas = new List { Guid.Parse("B2A0291C-84C7-4D86-A6D5-CB9FCCF4A2D8") }; list_projects.ForEach(p => { @@ -154,16 +192,31 @@ namespace Ewide.NbzsZheliban.Service p.BcxyList = bcxy; listAreas.Add(Guid.Parse(p.AreaID)); }); - //鏀跨瓥 - var list_PoliciesRegulations = await db.Queryable().Where(a => listAreas.Contains(a.AreaID)).Select(b => new PoliciesRegulation + List list_PoliciesRegulations = null; + var listPoliciesRegulationsTemp = _cache.Get>("CacheData-PoliciesRegulations"); + if (listPoliciesRegulationsTemp != null && listPoliciesRegulationsTemp.Count > 0) { - ID = b.ID, - Contents = b.Contents, - PublicTime = b.PublicTime, - Title = b.Title, - Area = b.Area - }).ToListAsync(); - + list_PoliciesRegulations = listPoliciesRegulationsTemp.Where(a => listAreas.Contains(a.AreaID)).Select(b => new PoliciesRegulation + { + ID = b.ID, + Contents = b.Contents, + PublicTime = b.PublicTime, + Title = b.Title, + Area = b.Area + }).ToList(); + } + else + { + //鏀跨瓥 + list_PoliciesRegulations = db.Queryable().Where(a => listAreas.Contains(a.AreaID)).Select(b => new PoliciesRegulation + { + ID = b.ID, + Contents = b.Contents, + PublicTime = b.PublicTime, + Title = b.Title, + Area = b.Area + }).ToList(); + } Nbzs.Entity.Extends.H5IndexModel h5IndexModel = new() { PrjList = list_projects, @@ -180,7 +233,8 @@ namespace Ewide.NbzsZheliban.Service var dbTicket = db.Queryable().Where(p => p.Ticket == ticket && p.ExpireTime > DateTime.Now).OrderBy(p => p.CreateTime, OrderByType.Desc).First(); if (dbTicket != null) { - return JObject.Parse(dbTicket.OriginalResponse); + var OriginalResponse = AESEncryption.Decrypt(dbTicket.OriginalResponse, Common.GetHashKey()); + return JObject.Parse(OriginalResponse); } else { @@ -233,11 +287,11 @@ namespace Ewide.NbzsZheliban.Service { ID = Guid.NewGuid().ToString(), Ticket = ticket, - IdCardNo = userinfoObj["idnum"].ToString(), + IdCardNo = AESEncryption.Encrypt(userinfoObj["idnum"].ToString(), Common.GetHashKey()), UserName = userinfoObj["username"].ToString(), ExpireTime = DateTime.Now.AddHours(4),//娴欓噷鍔炵殑token鏃舵晥涔熸槸4涓皬鏃 CreateTime = DateTime.Now, - OriginalResponse = userinfoRsltStr + OriginalResponse = AESEncryption.Encrypt(userinfoRsltStr, Common.GetHashKey()) }).ExecuteCommand(); if (temp1 <= 0) throw Oops.Oh("鍑虹幇寮傚父,璇疯仈绯荤鐞嗗憳"); diff --git a/Ewide.NbzsZheliban/Tools/Class1.cs b/Ewide.NbzsZheliban/Tools/Class1.cs deleted file mode 100644 index 9228ce5..0000000 --- a/Ewide.NbzsZheliban/Tools/Class1.cs +++ /dev/null @@ -1,12 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Ewide.NbzsZheliban.Tools -{ - public class Class1 - { - } -} diff --git a/Ewide.NbzsZheliban/Tools/Common.cs b/Ewide.NbzsZheliban/Tools/Common.cs new file mode 100644 index 0000000..6d70125 --- /dev/null +++ b/Ewide.NbzsZheliban/Tools/Common.cs @@ -0,0 +1,17 @@ +锘縰sing Furion; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.NbzsZheliban.Tools +{ + public class Common + { + public static string GetHashKey() + { + return App.GetConfig("AesHashKey"); + } + } +} diff --git a/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.dll index d025712..2c4ff87 100644 Binary files a/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.pdb b/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.pdb index f6bf229..be0213f 100644 Binary files a/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.pdb and b/Ewide.NbzsZheliban/bin/Debug/net5.0/Ewide.NbzsZheliban.pdb differ diff --git a/Ewide.NbzsZheliban/bin/Debug/net5.0/ref/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/bin/Debug/net5.0/ref/Ewide.NbzsZheliban.dll index 107b208..64283cc 100644 Binary files a/Ewide.NbzsZheliban/bin/Debug/net5.0/ref/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/bin/Debug/net5.0/ref/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.dll index 6a2cc6f..85176a7 100644 Binary files a/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.pdb b/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.pdb index f0581ad..b865bce 100644 Binary files a/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.pdb and b/Ewide.NbzsZheliban/bin/Release/net5.0/Ewide.NbzsZheliban.pdb differ diff --git a/Ewide.NbzsZheliban/bin/Release/net5.0/ref/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/bin/Release/net5.0/ref/Ewide.NbzsZheliban.dll index 8774c44..73dc8cf 100644 Binary files a/Ewide.NbzsZheliban/bin/Release/net5.0/ref/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/bin/Release/net5.0/ref/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache index f9fb45a..91eea0b 100644 Binary files a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache and b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache differ diff --git a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache index 3165967..e06913b 100644 --- a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache +++ b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -18b81abb8b32055668d7f327591b58a7f0a2cc3f +a934c94fb064d6bd60c0741398e1a004ca47a59e diff --git a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.dll index d025712..2c4ff87 100644 Binary files a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.pdb b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.pdb index f6bf229..be0213f 100644 Binary files a/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.pdb and b/Ewide.NbzsZheliban/obj/Debug/net5.0/Ewide.NbzsZheliban.pdb differ diff --git a/Ewide.NbzsZheliban/obj/Debug/net5.0/ref/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/obj/Debug/net5.0/ref/Ewide.NbzsZheliban.dll index 107b208..64283cc 100644 Binary files a/Ewide.NbzsZheliban/obj/Debug/net5.0/ref/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/obj/Debug/net5.0/ref/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache index 3f7e7e1..f11121e 100644 Binary files a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache and b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.AssemblyReference.cache differ diff --git a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache index ab4b5fc..a098b3a 100644 --- a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache +++ b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -8d49216a3c5aed4b88f30d5f0d3af55eeb105b22 +bb13473e3cc2466fdcf53d235e9bb0ae703fada9 diff --git a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.dll index 6a2cc6f..85176a7 100644 Binary files a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.dll differ diff --git a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.pdb b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.pdb index f0581ad..b865bce 100644 Binary files a/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.pdb and b/Ewide.NbzsZheliban/obj/Release/net5.0/Ewide.NbzsZheliban.pdb differ diff --git a/Ewide.NbzsZheliban/obj/Release/net5.0/ref/Ewide.NbzsZheliban.dll b/Ewide.NbzsZheliban/obj/Release/net5.0/ref/Ewide.NbzsZheliban.dll index 8774c44..73dc8cf 100644 Binary files a/Ewide.NbzsZheliban/obj/Release/net5.0/ref/Ewide.NbzsZheliban.dll and b/Ewide.NbzsZheliban/obj/Release/net5.0/ref/Ewide.NbzsZheliban.dll differ