Commit 7ebf9871 by 钟博

修改JobTitle过滤

parent 7193617a
......@@ -46,11 +46,11 @@ public IEnumerable<sub_jobtitle> GetJobTitle(int allotId, int hospitalId)
{
try
{
var jobTitleSql = $@"select * from sub_jobtitle where AllotID=@allotId and JobTitle is not null;";
var jobTitleSql = $@"select * from sub_jobtitle where AllotID=@allotId ";
var jobTitles = _dbConnection.Query<sub_jobtitle>(jobTitleSql, new { allotId });
if (jobTitles?.Count() > 0) return jobTitles;
jobTitles = _dbConnection.Query<sub_jobtitle>($@"SELECT DISTINCT JobTitle FROM db_performance_subsidy.sub_subsidy where AllotID=@allotId and JobTitle is not null;", new { allotId }).Select(t => new sub_jobtitle { JobTitle = t.JobTitle, BasicPerforFee = t.BasicPerforFee ?? 0 });
jobTitles = _dbConnection.Query<sub_jobtitle>($@"SELECT DISTINCT JobTitle FROM db_performance_subsidy.sub_subsidy where AllotID=@allotId ", new { allotId }).Select(t => new sub_jobtitle { JobTitle = t.JobTitle, BasicPerforFee = t.BasicPerforFee ?? 0 });
var allotOder = _dbConnection.Query<view_allot>($@"SELECT * from view_allot a WHERE a.HospitalId=@HospitalId ORDER BY a.`Year`,a.`Month`;", new { hospitalId }).ToList();
if (!allotOder.Any()) return jobTitles;
......@@ -82,7 +82,7 @@ public void GetHrpJobTitle(int allotId, int hospitalId, bool isRefresh)
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var subsidies = _dbConnection.Query<sub_subsidy>("select * from sub_subsidy where AllotID=@allotId and JobTitle is not null;", new { allotId });
var subsidies = _dbConnection.Query<sub_subsidy>("select * from sub_subsidy where AllotID=@allotId ", new { allotId });
if (subsidies.Any() && isRefresh == false) return;
var config = _dbConnection.QueryFirst<ex_config>("select * from ex_config where hospitalId=@hospitalId", new { hospitalId });
......@@ -91,15 +91,18 @@ public void GetHrpJobTitle(int allotId, int hospitalId, bool isRefresh)
var hrp = _dbConnection.QueryFirst<ex_script>("select * from ex_script;");
var res = connection.Query<sub_subsidy>(hrp?.ExecScript, new { allotId }, commandTimeout: _commandTimeout);
var subsidy = _dbConnection.Query<sub_jobtitle>("select * from sub_jobtitle where AllotID=@allotId and JobTitle is not null;", new { allotId }).Select(t => new { t.JobTitle, t.BasicPerforFee }).Distinct();
var subsidy = _dbConnection.Query<sub_jobtitle>("select * from sub_jobtitle where AllotID=@allotId ;", new { allotId }).Select(t => new { t.JobTitle, t.BasicPerforFee }).Distinct();
//删除:在点击重新加载时删除记录重新插入
_dbConnection.Execute("delete from sub_subsidy where AllotID=@allotId;delete from sub_jobtitle where AllotID=@allotId;", new { allotId });
var jobtitle = res.Select(t => new { allotId, t.JobTitle,
BasicPerforFee=subsidy.Where(w => w.JobTitle == t.JobTitle)?.Select(t => t.BasicPerforFee).FirstOrDefault() });
jobtitle = jobtitle.Distinct();
var jobtitle = res.Where(w=>!string.IsNullOrWhiteSpace(w.JobTitle)).Select(t => new
{
allotId,
t.JobTitle,
BasicPerforFee = subsidy.Where(w => w.JobTitle == t.JobTitle)?.Select(t => t.BasicPerforFee).FirstOrDefault()
}).Distinct();
var sql = $@"insert into sub_jobtitle(AllotID,JobTitle,BasicPerforFee) values (@allotId,@JobTitle,@BasicPerforFee);";
_dbConnection.Execute(sql, jobtitle);
......@@ -150,8 +153,7 @@ public List<sub_subsidy> GetJobTitleSubsidy(int allotId)
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
IEnumerable<sub_subsidy> _Subsidies = _dbConnection.Query<sub_subsidy>(@"
select * from sub_subsidy where JobTitle is not null and AllotID=@allotId ;", new { allotId });
IEnumerable<sub_subsidy> _Subsidies = _dbConnection.Query<sub_subsidy>(@"select * from sub_subsidy where AllotID=@allotId ;", new { allotId });
return _Subsidies?.ToList();
}
catch (Exception e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment