ปรับปรุงการนับคะแนนของคนที่คร่อมรอบ
This commit is contained in:
@@ -22,6 +22,7 @@ namespace TodoAPI2.Models
|
||||
eva_adjust_postponement_detail_normalWithSelectionViewModel GetBlankItem();
|
||||
|
||||
string ReCreatePostponementDetailNormal(eva_adjust_postponementEntity entity);
|
||||
string UpdatePostponementDetailNormal(eva_adjust_postponementEntity entity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ namespace TodoAPI2.Models
|
||||
public class eva_adjust_postponement_detail_normalService : Ieva_adjust_postponement_detail_normalService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponement_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponement_detail_normalService(IBaseRepository2<eva_adjust_postponement_detailEntity, int> repository,
|
||||
public eva_adjust_postponement_detail_normalService(IBaseRepository2<eva_adjust_postponement_detailEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detail_normalViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -84,12 +84,12 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_adjust_postponement_detail_normalViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id)
|
||||
{
|
||||
var model = new eva_adjust_postponement_detail_normalSearchModel();
|
||||
var model = new eva_adjust_postponement_detail_normalSearchModel();
|
||||
model.adjust_postponement_id = adjust_postponement_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_normalViewModel> GetListBySearch(eva_adjust_postponement_detail_normalSearchModel model)
|
||||
public List<eva_adjust_postponement_detail_normalViewModel> GetListBySearch(eva_adjust_postponement_detail_normalSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
@@ -104,15 +104,15 @@ 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_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()
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
//&& (m_eva_adjust_postponement_detail_normal.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail_normal.adjust_postponement_id == model.adjust_postponement_id || !model.adjust_postponement_id.HasValue)
|
||||
&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_normal.employee_id
|
||||
//&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_normal.employee_id
|
||||
|
||||
orderby m_eva_adjust_postponement_detail_normal.created descending
|
||||
select new eva_adjust_postponement_detail_normalViewModel()
|
||||
@@ -132,8 +132,11 @@ namespace TodoAPI2.Models
|
||||
emp_fullname = fk_external_linkageResult2.fullname,
|
||||
emp_position = fk_external_linkageResult2.position_name,
|
||||
emp_level = fk_external_linkageResult2.position_level_text,
|
||||
total_score = fk_create_detailResult.score_supervisor,
|
||||
eva_result = fk_create_detailResult.level_score_supervisor,
|
||||
|
||||
achievement = m_eva_adjust_postponement_detail_normal.achievement_final,
|
||||
competency = m_eva_adjust_postponement_detail_normal.competency_final,
|
||||
total_score = m_eva_adjust_postponement_detail_normal.score_final,
|
||||
eva_result = m_eva_adjust_postponement_detail_normal.level_score_final,
|
||||
|
||||
adjust_postponement_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult1.fiscal_year,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
@@ -156,10 +159,10 @@ namespace TodoAPI2.Models
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement_detail
|
||||
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;
|
||||
}
|
||||
@@ -175,7 +178,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
@@ -206,7 +209,7 @@ namespace TodoAPI2.Models
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string ReCreatePostponementDetailNormal(eva_adjust_postponementEntity entity)
|
||||
@@ -214,7 +217,7 @@ namespace TodoAPI2.Models
|
||||
int? adjust_postponement_id = entity.id;
|
||||
|
||||
var cylinder = (from z in _repository.Context.eva_salary_cylinder
|
||||
select z).ToList();
|
||||
select z).ToList();
|
||||
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
@@ -226,16 +229,19 @@ namespace TodoAPI2.Models
|
||||
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();
|
||||
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_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();
|
||||
|
||||
int newkey = GetNewPrimaryKey();
|
||||
decimal sum_salary = 0;
|
||||
@@ -246,7 +252,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
if (theemp == null) continue;
|
||||
|
||||
if (theemp.fullname.Contains("ธัญนันท์"))
|
||||
if (theemp.fullname.Contains("อุบลวรรณ"))
|
||||
{
|
||||
string zz = "1";
|
||||
}
|
||||
@@ -268,32 +274,53 @@ namespace TodoAPI2.Models
|
||||
else
|
||||
{
|
||||
n.sarary = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var c = getCylinderForEmployee(theemp, cylinder);
|
||||
|
||||
n.middle = 0;
|
||||
|
||||
n.middle = 0;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
n.middle = c.middle;
|
||||
}
|
||||
|
||||
|
||||
n.promoted_percentage = 0; // ร้อยละที่ได้เลื่อน
|
||||
n.total_promote = 0; // จำนวนเงินที่ได้เลื่อน
|
||||
n.new_sarary = n.sarary;
|
||||
n.new_cost_living = n.cost_living;
|
||||
if(theemp.worked_month < 4)
|
||||
if (theemp.worked_month < 4)
|
||||
{
|
||||
n.remark = "ปฏิบัติงานไม่ครบ 4 เดือน";
|
||||
}
|
||||
|
||||
|
||||
n.receive_quota = 0;
|
||||
n.new_sarary_with_quota = n.sarary;
|
||||
|
||||
n.created = DateTime.Now;
|
||||
n.updated = DateTime.Now;
|
||||
n.isActive = true;
|
||||
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;
|
||||
}
|
||||
|
||||
_repository.Context.eva_adjust_postponement_detail.Add(n);
|
||||
}
|
||||
@@ -305,41 +332,142 @@ namespace TodoAPI2.Models
|
||||
return current_eva_evaluation_group_detail.Count().ToString();
|
||||
}
|
||||
|
||||
private eva_salary_cylinderEntity getCylinderForEmployee(external_employeeViewModel theemp,
|
||||
public string UpdatePostponementDetailNormal(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;
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private eva_salary_cylinderEntity getCylinderForEmployee(external_employeeViewModel theemp,
|
||||
List<eva_salary_cylinderEntity> all_cylinder)
|
||||
{
|
||||
{
|
||||
var c = (from i in all_cylinder
|
||||
where i.position_level == theemp.position_level_id
|
||||
&& i.position_type == theemp.position_type_id
|
||||
select i).FirstOrDefault();
|
||||
where i.position_level == theemp.position_level_id
|
||||
&& i.position_type == theemp.position_type_id
|
||||
select i).FirstOrDefault();
|
||||
return c;
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_detail_normalInputModel> model)
|
||||
{
|
||||
foreach(var i in 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.adjust_postponement_id = i.adjust_postponement_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.promoted_percentage = i.promoted_percentage;
|
||||
existingEntity.total_promote = i.total_promote;
|
||||
existingEntity.new_sarary = i.new_sarary;
|
||||
existingEntity.new_cost_living = i.new_cost_living;
|
||||
existingEntity.remark = i.remark;
|
||||
//existingEntity.emp_code = i.emp_code;
|
||||
//existingEntity.emp_fullname = i.emp_fullname;
|
||||
//existingEntity.emp_position = i.emp_position;
|
||||
//existingEntity.emp_level = i.emp_level;
|
||||
//existingEntity.total_score = i.total_score;
|
||||
//existingEntity.eva_result = i.eva_result;
|
||||
existingEntity.adjust_postponement_id = i.adjust_postponement_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.promoted_percentage = i.promoted_percentage;
|
||||
existingEntity.total_promote = i.total_promote;
|
||||
existingEntity.new_sarary = i.new_sarary;
|
||||
existingEntity.new_cost_living = i.new_cost_living;
|
||||
existingEntity.remark = i.remark;
|
||||
//existingEntity.emp_code = i.emp_code;
|
||||
//existingEntity.emp_fullname = i.emp_fullname;
|
||||
//existingEntity.emp_position = i.emp_position;
|
||||
//existingEntity.emp_level = i.emp_level;
|
||||
//existingEntity.total_score = i.total_score;
|
||||
//existingEntity.eva_result = i.eva_result;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
@@ -352,15 +480,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();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public string emp_level { get; set; }
|
||||
|
||||
public decimal? achievement { get; set; }
|
||||
|
||||
public decimal? competency { get; set; }
|
||||
|
||||
public decimal? total_score { get; set; }
|
||||
|
||||
public string eva_result { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user