ปรับปรุงการแสดงผล

This commit is contained in:
LAPTOP-KB8JC2K2\acer
2021-04-21 07:53:48 +07:00
parent 41c1a276f9
commit 31f21f24ad
5 changed files with 164 additions and 66 deletions

View File

@@ -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;

View File

@@ -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,15 +369,10 @@ 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
select t).FirstOrDefault();
select t).FirstOrDefault();
n.updated = DateTime.Now;
n.isActive = true;
@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -20,18 +20,18 @@ namespace TodoAPI2.Models
public class eva_adjust_postponement_quotaService : Ieva_adjust_postponement_quotaService
{
private IBaseRepository2<eva_adjust_postponementEntity, int> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
private Ieva_adjust_postponement_detail_quota_02Service quota02;
public eva_adjust_postponement_quotaService(IBaseRepository2<eva_adjust_postponementEntity, int> repository, IMyDatabase mydb,
public eva_adjust_postponement_quotaService(IBaseRepository2<eva_adjust_postponementEntity, int> repository, IMyDatabase mydb,
Iexternal_linkageService inext, Iexternal_employeeService inemp,
Ieva_adjust_postponement_detail_quota_02Service inquota02)
{
_repository = repository;
db = mydb;
ext = inext;
db = mydb;
ext = inext;
emp = inemp;
quota02 = inquota02;
}
@@ -53,7 +53,7 @@ namespace TodoAPI2.Models
{
return Mapper.Map<List<eva_adjust_postponement_quotaViewModel>>(entities);
}
#endregion
#region Public Functions
@@ -85,12 +85,12 @@ namespace TodoAPI2.Models
public List<eva_adjust_postponement_quotaViewModel> GetListByfiscal_year(int? fiscal_year)
{
var model = new eva_adjust_postponement_quotaSearchModel();
var model = new eva_adjust_postponement_quotaSearchModel();
model.fiscal_year = fiscal_year;
return GetListBySearch(model);
}
public List<eva_adjust_postponement_quotaViewModel> GetListBySearch(eva_adjust_postponement_quotaSearchModel model)
public List<eva_adjust_postponement_quotaViewModel> GetListBySearch(eva_adjust_postponement_quotaSearchModel model)
{
var all_emp = emp.GetListByemployee_type(null, null);
@@ -100,8 +100,8 @@ namespace TodoAPI2.Models
join fk_external_linkage7 in all_emp on m_eva_adjust_postponement_quota.managed_by equals fk_external_linkage7.id
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)
@@ -140,10 +140,10 @@ namespace TodoAPI2.Models
int? newkey = 0;
var x = (from i in _repository.Context.eva_adjust_postponement
orderby i.id descending
select i).Take(1).ToList();
orderby i.id descending
select i).Take(1).ToList();
if(x.Count > 0)
if (x.Count > 0)
{
newkey = x[0].id + 1;
}
@@ -179,7 +179,7 @@ namespace TodoAPI2.Models
entity.limit = AddMultipleDetail(entity.id, all_emp_id_list, entity.fiscal_year, entity.theRound, all_emp);
var inserted = _repository.Insert(entity);
return Get(inserted.id);
}
@@ -203,7 +203,7 @@ namespace TodoAPI2.Models
where x.adjust_postponement_quota_id == adjust_postponement_quota_id
select x.employee_id).ToList();
foreach (var i in model)
{
@@ -215,7 +215,7 @@ namespace TodoAPI2.Models
if (theemp.salary.HasValue)
{
sum_salary += theemp.salary.Value;
}
}
var q = (from p in _repository.Context.eva_adjust_postponement_detail
where p.employee_id == i
@@ -326,31 +326,129 @@ 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);
return Get(updated.id);
}
else
throw new NotificationException("No data to update");
throw new NotificationException("No data to update");
}
public string UpdateMultiple(List<eva_adjust_postponement_quotaInputModel> model)
public string UpdatePostponementDetailQuota(eva_adjust_postponementEntity entity)
{
foreach(var i in model)
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)
{
if (i.active_mode == "1" && i.id.HasValue) // update
{
{
var existingEntity = _repository.Get(i.id.Value);
if (existingEntity != null)
{
existingEntity.fiscal_year = i.fiscal_year;
existingEntity.theDate = i.theDate;
existingEntity.theRound = i.theRound;
existingEntity.limit_quota = i.limit_quota;
existingEntity.limit_frame_quota = i.limit_frame_quota;
existingEntity.command_no = i.command_no;
existingEntity.managed_by = i.managed_by;
existingEntity.fiscal_year = i.fiscal_year;
existingEntity.theDate = i.theDate;
existingEntity.theRound = i.theRound;
existingEntity.limit_quota = i.limit_quota;
existingEntity.limit_frame_quota = i.limit_frame_quota;
existingEntity.command_no = i.command_no;
existingEntity.managed_by = i.managed_by;
// limit
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
@@ -363,15 +461,15 @@ namespace TodoAPI2.Models
_repository.InsertWithoutCommit(entity);
}
else if (i.active_mode == "0" && i.id.HasValue) // remove
{
{
_repository.DeleteWithoutCommit(i.id.Value);
}
else if (i.active_mode == "0" && !i.id.HasValue)
{
// nothing to do
}
}
}
_repository.Context.SaveChanges();
_repository.Context.SaveChanges();
return model.Count().ToString();
}
@@ -396,10 +494,10 @@ namespace TodoAPI2.Models
_repository.Context.RemoveRange(data);
var data2 = from i in _repository.Context.eva_adjust_postponement_detail
where i.adjust_postponement_quota_id == id && i.adjust_postponement_id != null
select i;
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;
}