add 增加缓存 ,
解决往外推送时偶尔中断的问题 . 增加敏感信息加密功能
This commit is contained in:
@@ -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<CacheOptions>(new CacheOptions
|
||||
{
|
||||
CacheType = CacheType.RedisCache,
|
||||
RedisConnectionString = App.GetConfig<string>("RedisConfig")
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,8 +99,12 @@ namespace Ewide.NbzsZheliban.Service
|
||||
/// <returns></returns>
|
||||
private async Task<List<Dcbs>> GetzzDcbsAsync(string cardno)
|
||||
{
|
||||
//住宅调查表
|
||||
return await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from InvestigateTable b where b.ExpropriatedCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
|
||||
var list = _cache.Get<List<Dcbs>>("CacheData-InvestigateTable");
|
||||
if (list != null && list.Count > 0)
|
||||
return list.Where(p => p.ExpropriatedCardNo == cardno).ToList();
|
||||
else
|
||||
//住宅调查表
|
||||
return await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from InvestigateTable b where b.ExpropriatedCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
|
||||
}
|
||||
/// <summary>
|
||||
/// 非住宅调查表
|
||||
@@ -102,8 +113,12 @@ namespace Ewide.NbzsZheliban.Service
|
||||
/// <returns></returns>
|
||||
private async Task<List<Dcbs>> GetfzzDcbsAsync(string cardno)
|
||||
{
|
||||
//非住宅调查表
|
||||
return await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from NonResidentialInvestigateTable b where b.PropertyRightPrsonCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
|
||||
var list = _cache.Get<List<Dcbs>>("CacheData-NonResidentialInvestigateTable");
|
||||
if (list != null && list.Count > 0)
|
||||
return list.Where(p => p.ExpropriatedCardNo == cardno).ToList();
|
||||
else
|
||||
//非住宅调查表
|
||||
return await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from NonResidentialInvestigateTable b where b.PropertyRightPrsonCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
|
||||
}
|
||||
/// <summary>
|
||||
/// 项目列表
|
||||
@@ -112,39 +127,62 @@ namespace Ewide.NbzsZheliban.Service
|
||||
/// <returns></returns>
|
||||
private async Task<List<H5IndexPrjModel>> GetPrjListAsync(IEnumerable<Dcbs> list_dcbs)
|
||||
{
|
||||
//项目列表
|
||||
return await db.Ado.SqlQueryAsync<H5IndexPrjModel>("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<List<H5IndexPrjModel>>("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<H5IndexPrjModel>("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)) + "') ");
|
||||
}
|
||||
/// <summary>
|
||||
/// 分户评估
|
||||
/// </summary>
|
||||
/// <param name="InvestigateTableID_param"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<Fhpgs>> GetFHPGListAsync(string InvestigateTableID_param)
|
||||
private async Task<List<Fhpgs>> GetFHPGListAsync(IEnumerable<Dcbs> list_dcbs)
|
||||
{
|
||||
//分户评估
|
||||
return await db.Ado.SqlQueryAsync<Fhpgs>("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<List<Fhpgs>>("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<Fhpgs>("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 + " ) ;");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 补偿协议
|
||||
/// </summary>
|
||||
/// <param name="InvestigateTableID_param"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<Bcxy>> GetBCXYListAsync(string InvestigateTableID_param)
|
||||
private async Task<List<Bcxy>> GetBCXYListAsync(IEnumerable<Dcbs> list_dcbs)
|
||||
{
|
||||
//补偿协议
|
||||
return await db.Ado.SqlQueryAsync<Bcxy>("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<List<Bcxy>>("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<Bcxy>("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<H5IndexModel> 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);
|
||||
////解密
|
||||
//list_bcxys.ForEach(xy=> {
|
||||
//xy.ExpropriatedCardNo= AESEncryption.Decrypt(xy.ExpropriatedCardNo, Common.GetHashKey());
|
||||
//});
|
||||
var listAreas = new List<Guid?> { 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<Nbzs.Entity.PoliciesRegulations>().Where(a => listAreas.Contains(a.AreaID)).Select(b => new PoliciesRegulation
|
||||
List<PoliciesRegulation> list_PoliciesRegulations = null;
|
||||
var listPoliciesRegulationsTemp = _cache.Get<List<Nbzs.Entity.PoliciesRegulations>>("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<Nbzs.Entity.PoliciesRegulations>().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<zjzwfwTickets>().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("出现异常,请联系管理员");
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.NbzsZheliban.Tools
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
17
Ewide.NbzsZheliban/Tools/Common.cs
Normal file
17
Ewide.NbzsZheliban/Tools/Common.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using 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<string>("AesHashKey");
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
18b81abb8b32055668d7f327591b58a7f0a2cc3f
|
||||
a934c94fb064d6bd60c0741398e1a004ca47a59e
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
8d49216a3c5aed4b88f30d5f0d3af55eeb105b22
|
||||
bb13473e3cc2466fdcf53d235e9bb0ae703fada9
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user