add 增加缓存 ,

解决往外推送时偶尔中断的问题 .
增加敏感信息加密功能
This commit is contained in:
路 范
2021-10-20 14:30:42 +08:00
parent 1d7e944df2
commit 238615b668
25 changed files with 282 additions and 78 deletions

View File

@@ -46,5 +46,9 @@ namespace Ewide.Nbzs.BackWorkerService
{
return GetDbClient().GetConnection(id);
}
public static string GetHashKey()
{
return App.GetConfig<string>("AesHashKey");
}
}
}

View File

@@ -6,12 +6,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ewide.Nbzs.Entity\Ewide.Nbzs.Entity.csproj" />
<ProjectReference Include="..\framework\Api\Ewide.Core\Ewide.Core.csproj" />
<ProjectReference Include="..\framework\Api\Furion\framework\Furion.Extras.DatabaseAccessor.SqlSugar\Furion.Extras.DatabaseAccessor.SqlSugar.csproj" />
<ProjectReference Include="..\framework\Api\Furion\framework\Furion.Extras.Logging.Serilog\Furion.Extras.Logging.Serilog.csproj" />
<ProjectReference Include="..\framework\Api\Furion\framework\Furion\Furion.csproj" />

View File

@@ -24,6 +24,13 @@ namespace Ewide.Nbzs.BackWorkerService
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
services.AddStackExchangeRedisCache(options =>
{
// 连接字符串,这里也可以读取配置文件
options.Configuration = App.GetConfig<string>("RedisConfig");
// 键名前缀
options.InstanceName = "zlb_";
});
}).UseSerilogDefault();
}
}

View File

@@ -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<Worker> _logger;
readonly SqlSugarProvider db_Product_Conn;
readonly SqlSugarProvider db_Zlb_Conn;
//private readonly IDistributedCache _cache;
private readonly ICache _cache;
//, IDistributedCache cache
public Worker(ILogger<Worker> 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<CacheOptions>(new CacheOptions
{
CacheType = CacheType.RedisCache,
RedisConnectionString = App.GetConfig<string>("RedisConfig")
}));
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
@@ -88,6 +102,7 @@ namespace Ewide.Nbzs.BackWorkerService
private List<PushResult> Push(PushZlb pushZlbObj)
{
//测试读取接口中缓存
_logger.LogInformation("进入Push方法():Id:{Id} ,项目ID:{PrjId} at: {time}", pushZlbObj.ID, pushZlbObj.PrjId, DateTimeOffset.Now);
List<PushResult> list_result = new();
try
@@ -96,80 +111,181 @@ namespace Ewide.Nbzs.BackWorkerService
var project = db_Product_Conn.Queryable<Projects>().Where(p => p.ID == projectId).First();
if (project != null)
{
#region
_cache.Set($"CacheData-PoliciesRegulations", db_Zlb_Conn.Queryable<Entity.PoliciesRegulations>().ToList());
var listPoliciesRegulations = db_Product_Conn.Queryable<Entity.PoliciesRegulations>().ToList();
//_cache.SetString($"CacheData-PoliciesRegulations", JSON.Serialize(listPoliciesRegulations), new DistributedCacheEntryOptions
//{
// SlidingExpiration = TimeSpan.FromMinutes(60)
//});
//删政策
var delete_result = db_Zlb_Conn.Deleteable<PoliciesRegulations>().ExecuteCommandHasChange();
var delete_result = db_Zlb_Conn.Deleteable<Entity.PoliciesRegulations>().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<Entity.PoliciesRegulations>().ToList());
#endregion
#region
_cache.Set($"CacheData-ResidentialAgreement", GetBcxyData());
//if (delete_result)
//{
var insert_result = db_Zlb_Conn.Insertable(db_Product_Conn.Queryable<PoliciesRegulations>().ToList()).ExecuteCommand();
list_result.Add(new PushResult { Action = "Insert", TableName = "PoliciesRegulations", IsSuccess = insert_result > 0 });
//}
//加密敏感字段
var listNonResidentialAgreement = db_Product_Conn.Queryable<NonResidentialAgreement>().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<NonResidentialAgreement>().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<NonResidentialAgreement>().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<ResidentialAgreement>().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<ResidentialAgreement>().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<ResidentialAgreement>().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<NonInvestigateTable_Assessment>().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<NonInvestigateTable_Assessment>().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<NonInvestigateTable_Assessment>().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<InvestigateTable_Assessment>().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<InvestigateTable_Assessment>().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<InvestigateTable_Assessment>().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<NonResidentialInvestigateTable>().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, ExpropriatedCardNo = p.PropertyRightPrsonCardNo }).ToList());
//删除非住宅调查表
delete_result = db_Zlb_Conn.Deleteable<NonResidentialInvestigateTable>().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<NonResidentialInvestigateTable>().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<NonResidentialInvestigateTable>().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<NonResidentialInvestigateTable>().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, ExpropriatedCardNo = p.PropertyRightPrsonCardNo }).ToList());
#endregion
#region
_cache.Set($"CacheData-InvestigateTable", db_Zlb_Conn.Queryable<InvestigateTable>().Select(p => new { dcbId = p.ID, PrjId = p.ProjectId, p.ExpropriatedCardNo }).ToList());
//删除住宅调查表
delete_result = db_Zlb_Conn.Deleteable<InvestigateTable>().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<InvestigateTable>().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<InvestigateTable>().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<InvestigateTable>().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<Projects>().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<Projects>().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<Projects>().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<ProjectsStep>().ToList());
var listProjectsStep = db_Product_Conn.Queryable<ProjectsStep>().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<ProjectsStep>().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<ProjectsStep>().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<ProjectsStep>().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<H5IndexPrjModel> GetProjectData()
{
return db_Zlb_Conn.Ado.SqlQuery<H5IndexPrjModel>("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<Fhpgs> GetFHPGData()
{
return db_Zlb_Conn.Ado.SqlQuery<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 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<Bcxy> GetBcxyData()
{
return db_Zlb_Conn.Ado.SqlQuery<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 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
{

View File

@@ -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!@#"
}

View File

@@ -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
/// 补偿协议集合
/// </summary>
public List<Bcxy> BcxyList { get; set; }
public int status { get; set; }
}
public class PoliciesRegulations
{

View File

@@ -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("出现异常,请联系管理员");

View File

@@ -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
{
}
}

View 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");
}
}
}

View File

@@ -1 +1 @@
18b81abb8b32055668d7f327591b58a7f0a2cc3f
a934c94fb064d6bd60c0741398e1a004ca47a59e

View File

@@ -1 +1 @@
8d49216a3c5aed4b88f30d5f0d3af55eeb105b22
bb13473e3cc2466fdcf53d235e9bb0ae703fada9