ปรับปรุงการแสดงผล
This commit is contained in:
@@ -210,8 +210,8 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.adjust_postponement_id = model.adjust_postponement_id;
|
||||
existingEntity.adjust_postponement_quota_id = model.adjust_postponement_quota_id;
|
||||
//existingEntity.adjust_postponement_id = model.adjust_postponement_id;
|
||||
//existingEntity.adjust_postponement_quota_id = model.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.sarary = model.sarary;
|
||||
existingEntity.cost_living = model.cost_living;
|
||||
@@ -253,8 +253,8 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.adjust_postponement_id = i.adjust_postponement_id;
|
||||
existingEntity.adjust_postponement_quota_id = i.adjust_postponement_quota_id;
|
||||
//existingEntity.adjust_postponement_id = i.adjust_postponement_id;
|
||||
//existingEntity.adjust_postponement_quota_id = i.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
|
||||
@@ -322,6 +322,9 @@ namespace TodoAPI2.Models
|
||||
n.level_score_final = qq;
|
||||
}
|
||||
|
||||
//n.migration_total_score = n.score_final;
|
||||
//n.migration_eva_result = n.level_score_final;
|
||||
|
||||
_repository.Context.eva_adjust_postponement_detail.Add(n);
|
||||
}
|
||||
|
||||
@@ -366,11 +369,6 @@ namespace TodoAPI2.Models
|
||||
|
||||
if (theemp == null) continue;
|
||||
|
||||
if (theemp.fullname.Contains("อุบลวรรณ"))
|
||||
{
|
||||
string zz = "1";
|
||||
}
|
||||
|
||||
var n = (from t in _repository.Context.eva_adjust_postponement_detail
|
||||
where t.adjust_postponement_id == entity.id
|
||||
&& t.employee_id == m.employee_id
|
||||
@@ -399,7 +397,8 @@ namespace TodoAPI2.Models
|
||||
select s.detail).FirstOrDefault();
|
||||
n.level_score_final = qq;
|
||||
}
|
||||
|
||||
//n.migration_total_score = n.score_final;
|
||||
//n.migration_eva_result = n.level_score_final;
|
||||
}
|
||||
|
||||
entity.limit = sum_salary;
|
||||
|
||||
@@ -108,10 +108,10 @@ namespace TodoAPI2.Models
|
||||
into eva_adjust_postponementResult1
|
||||
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
|
||||
|
||||
join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
into create_detailResult
|
||||
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
//join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
// on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
// into create_detailResult
|
||||
//from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
|
||||
join create_data in _repository.Context.eva_create_evaluation
|
||||
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_data.id
|
||||
@@ -149,7 +149,7 @@ namespace TodoAPI2.Models
|
||||
//&& (m_eva_adjust_postponement_detail_normal_02.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail_normal_02.adjust_postponement_id == model.adjust_postponement_id || !model.adjust_postponement_id.HasValue)
|
||||
//&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_normal_02.employee_id
|
||||
&& (m_eva_adjust_postponement_detail_normal_02.is_for_postponement == null?true: m_eva_adjust_postponement_detail_normal_02.is_for_postponement.Value)
|
||||
//&& (m_eva_adjust_postponement_detail_normal_02.is_for_postponement == null?true: m_eva_adjust_postponement_detail_normal_02.is_for_postponement.Value)
|
||||
&& fk_external_linkageResult2.workingstatus == "สถานะปฏิบัติงาน"
|
||||
|
||||
orderby
|
||||
@@ -180,8 +180,9 @@ namespace TodoAPI2.Models
|
||||
|
||||
achievement = m_eva_adjust_postponement_detail_normal_02.achievement_final,
|
||||
competency = m_eva_adjust_postponement_detail_normal_02.competency_final,
|
||||
total_score = m_eva_adjust_postponement_detail_normal_02.score_final,
|
||||
eva_result = m_eva_adjust_postponement_detail_normal_02.level_score_final,
|
||||
|
||||
total_score = m_eva_adjust_postponement_detail_normal_02.migration_total_score.HasValue ? m_eva_adjust_postponement_detail_normal_02.migration_total_score : m_eva_adjust_postponement_detail_normal_02.score_final,
|
||||
eva_result = !string.IsNullOrEmpty(m_eva_adjust_postponement_detail_normal_02.migration_eva_result) ? m_eva_adjust_postponement_detail_normal_02.migration_eva_result : m_eva_adjust_postponement_detail_normal_02.level_score_final,
|
||||
|
||||
emp_department_name = fk_external_linkageResult2.department_name,
|
||||
|
||||
|
||||
@@ -112,10 +112,10 @@ namespace TodoAPI2.Models
|
||||
into eva_adjust_postponementResult1A
|
||||
from fk_eva_adjust_postponementResult1A in eva_adjust_postponementResult1A.DefaultIfEmpty()
|
||||
|
||||
join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
into create_detailResult
|
||||
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
//join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
// on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
// into create_detailResult
|
||||
//from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
|
||||
join create_data in _repository.Context.eva_create_evaluation
|
||||
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_data.id
|
||||
@@ -144,12 +144,12 @@ namespace TodoAPI2.Models
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
into create_detailResult
|
||||
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
//join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
//on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
//into create_detailResult
|
||||
//from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
|
||||
join sort_dep in ext.GetSortingDep() on fk_create_detailResult.help_org_id.HasValue ? fk_create_detailResult.help_org_id : fk_external_linkageResult2.department_id equals sort_dep.id
|
||||
join sort_dep in ext.GetSortingDep() on m_eva_adjust_postponement_detail_quota_02.org_at_this_time.HasValue ? m_eva_adjust_postponement_detail_quota_02.org_at_this_time : fk_external_linkageResult2.department_id equals sort_dep.id
|
||||
into sort_depResult2
|
||||
from fk_sort_depResult2 in sort_depResult2.DefaultIfEmpty()
|
||||
|
||||
@@ -158,22 +158,22 @@ namespace TodoAPI2.Models
|
||||
into create_dataResult
|
||||
from fk_create_dataResult in create_dataResult.DefaultIfEmpty()
|
||||
|
||||
join sort_dep2 in ext.GetSortingDep() on fk_create_detailResult.help_org_id equals sort_dep2.id
|
||||
join sort_dep2 in ext.GetSortingDep() on m_eva_adjust_postponement_detail_quota_02.org_at_this_time equals sort_dep2.id
|
||||
into external_linkageResult11
|
||||
from fk_external_linkageResult11 in sort_depResult2.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement_detail_quota_02.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail_quota_02.adjust_postponement_quota_id == model.adjust_postponement_quota_id || !model.adjust_postponement_quota_id.HasValue)
|
||||
&& (fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_quota_02.employee_id || fk_create_detailResult == null)
|
||||
//&& (fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_quota_02.employee_id || fk_create_detailResult == null)
|
||||
|
||||
&& (m_eva_adjust_postponement_detail_quota_02.is_for_postponement == null ? true : m_eva_adjust_postponement_detail_quota_02.is_for_postponement.Value)
|
||||
//&& (m_eva_adjust_postponement_detail_quota_02.is_for_postponement == null ? true : m_eva_adjust_postponement_detail_quota_02.is_for_postponement.Value)
|
||||
&& fk_external_linkageResult2.workingstatus == "สถานะปฏิบัติงาน"
|
||||
|
||||
orderby
|
||||
fk_sort_depResult2.external_code,
|
||||
|
||||
fk_create_detailResult.help_org_id.HasValue ? 1 : 0,
|
||||
m_eva_adjust_postponement_detail_quota_02.org_at_this_time.HasValue ? 1 : 0,
|
||||
|
||||
//fk_external_linkageResult2.department_degree_id,
|
||||
//fk_external_linkageResult2.department_code,
|
||||
@@ -203,8 +203,8 @@ namespace TodoAPI2.Models
|
||||
|
||||
emp_department_name = !string.IsNullOrEmpty(fk_external_linkageResult11.external_name) ? fk_external_linkageResult11.external_name : fk_sort_depResult2.external_name,
|
||||
|
||||
total_score = fk_create_detailResult.score_supervisor,
|
||||
eva_result = fk_create_detailResult.level_score_supervisor,
|
||||
total_score = m_eva_adjust_postponement_detail_quota_02.migration_total_score.HasValue? m_eva_adjust_postponement_detail_quota_02.migration_total_score : m_eva_adjust_postponement_detail_quota_02.score_final,
|
||||
eva_result = !string.IsNullOrEmpty(m_eva_adjust_postponement_detail_quota_02.migration_eva_result) ? m_eva_adjust_postponement_detail_quota_02.migration_eva_result : m_eva_adjust_postponement_detail_quota_02.level_score_final,
|
||||
|
||||
adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult1.fiscal_year,
|
||||
position_allowance = fk_external_linkageResult2.position_allowance,
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace TodoAPI2.Models
|
||||
into external_linkageResult7
|
||||
from fk_external_linkageResult7 in external_linkageResult7.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
//&& (m_eva_adjust_postponement_quota.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_quota.fiscal_year == model.fiscal_year || !model.fiscal_year.HasValue)
|
||||
&& (m_eva_adjust_postponement_quota.theRound == model.theRound || !model.theRound.HasValue)
|
||||
@@ -143,7 +143,7 @@ namespace TodoAPI2.Models
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
@@ -326,6 +326,7 @@ namespace TodoAPI2.Models
|
||||
existingEntity.managed_by = model.managed_by;
|
||||
// limit
|
||||
|
||||
UpdatePostponementDetailQuota(existingEntity);
|
||||
quota02.UpdateMultiple(model.adjust_postponement_detail_quota_02_model);
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
@@ -335,9 +336,106 @@ namespace TodoAPI2.Models
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdatePostponementDetailQuota(eva_adjust_postponementEntity entity)
|
||||
{
|
||||
int? adjust_postponement_id = entity.id;
|
||||
|
||||
var cylinder = (from z in _repository.Context.eva_salary_cylinder
|
||||
select z).ToList();
|
||||
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var adjust_postponement = entity;
|
||||
|
||||
var evaluation_group_id = (from m in _repository.Context.eva_create_evaluation
|
||||
where m.id == adjust_postponement.create_evaluation_id
|
||||
select m.evaluation_group_id).FirstOrDefault();
|
||||
|
||||
var current_eva_evaluation_group_detail = from k in _repository.Context.eva_evaluation_group_detail
|
||||
where k.evaluation_group_id == evaluation_group_id
|
||||
select k;
|
||||
|
||||
var current_eva_create_evaluation_detail = from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.create_evaluation_id == adjust_postponement.create_evaluation_id
|
||||
select k;
|
||||
|
||||
var current_level_score = (from e in _repository.Context.eva_level_score
|
||||
select e).ToList();
|
||||
|
||||
decimal sum_salary = 0;
|
||||
|
||||
foreach (var m in current_eva_evaluation_group_detail)
|
||||
{
|
||||
var theemp = (from i in all_emp where i.id == m.employee_id select i).FirstOrDefault();
|
||||
|
||||
if (theemp == null) continue;
|
||||
|
||||
var n = (from t in _repository.Context.eva_adjust_postponement_detail
|
||||
where t.adjust_postponement_quota_id == entity.id
|
||||
&& t.employee_id == m.employee_id
|
||||
select t).FirstOrDefault();
|
||||
|
||||
n.updated = DateTime.Now;
|
||||
n.isActive = true;
|
||||
|
||||
var temp = (from z in current_eva_create_evaluation_detail
|
||||
where z.employee_id == n.employee_id
|
||||
select new
|
||||
{
|
||||
achievement_final = getData(z).Item1.HasValue ? getData(z).Item1 : 0,
|
||||
competency_final = getData(z).Item2.HasValue ? getData(z).Item2 : 0,
|
||||
score_final = getData(z).Item3.HasValue ? getData(z).Item3 : 0,
|
||||
work_period = getData(z).Item4.HasValue ? getData(z).Item4 : 6,
|
||||
});
|
||||
|
||||
n.achievement_final = temp.Sum(w => w.achievement_final * w.work_period / 6);
|
||||
n.competency_final = temp.Sum(w => w.competency_final * w.work_period / 6);
|
||||
n.score_final = temp.Sum(w => w.score_final * w.work_period / 6);
|
||||
if (n.score_final.HasValue)
|
||||
{
|
||||
var qq = (from s in current_level_score
|
||||
where s.min_score <= n.score_final && s.max_score >= n.score_final
|
||||
select s.detail).FirstOrDefault();
|
||||
n.level_score_final = qq;
|
||||
}
|
||||
//n.migration_total_score = n.score_final;
|
||||
//n.migration_eva_result = n.level_score_final;
|
||||
}
|
||||
|
||||
entity.limit = sum_salary;
|
||||
|
||||
//_repository.Context.SaveChanges();
|
||||
|
||||
return current_eva_evaluation_group_detail.Count().ToString();
|
||||
}
|
||||
|
||||
private (decimal?, decimal?, decimal?, decimal?) getData(eva_create_evaluation_detailEntity detail)
|
||||
{
|
||||
if (detail.status_supervisor2A == "Y")
|
||||
{
|
||||
return (detail.achievement_supervisor2A, detail.competency_supervisor2A, detail.score_supervisor2A, detail.work_period);
|
||||
}
|
||||
else if (detail.status_supervisor1A == "Y")
|
||||
{
|
||||
return (detail.achievement_supervisor1A, detail.competency_supervisor1A, detail.score_supervisor1A, detail.work_period);
|
||||
}
|
||||
else if (detail.status_supervisor == "Y")
|
||||
{
|
||||
return (detail.achievement_supervisor, detail.competency_supervisor, detail.score_supervisor, detail.work_period);
|
||||
}
|
||||
else if (detail.status_chief == "Y")
|
||||
{
|
||||
return (detail.achievement_chief, detail.competency_chief, detail.score_chief, detail.work_period);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (0, 0, 0, detail.work_period);
|
||||
}
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_quotaInputModel> model)
|
||||
{
|
||||
foreach(var i in model)
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
@@ -399,7 +497,7 @@ namespace TodoAPI2.Models
|
||||
where i.adjust_postponement_quota_id == id && i.adjust_postponement_id != null
|
||||
select i;
|
||||
|
||||
foreach(var i in data2)
|
||||
foreach (var i in data2)
|
||||
{
|
||||
i.adjust_postponement_quota_id = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user